title: WildFly - HornetQ connection timeout and performance issue
body: <p>In a WildFly 8.2.1-Final high-volume installation we are experiencing degrading performance within about a week until restart is necessary along with more and more frequently occurring failures to send JMS messages because of transactions in state ABORT_ONLY:</p>
  
  <pre><code>Caused by: javax.ejb.EJBException: javax.jms.JMSException: Could not create a session: IJ000457: Unchecked throwable in managedConnectionReconnected()
  Caused by: javax.resource.ResourceException: IJ000457: Unchecked throwable in managedConnectionReconnected() cl=org.jboss.jca.core.connectionmanager.listener.TxConnectionListener@3915e409[state=NORMAL managed connection=org.hornetq.ra.HornetQRAManagedConnection@7d6bcd06 connection handles=0 lastUse=1494579251303 trackByTx=false pool=org.jboss.jca.core.connectionmanager.pool.strategy.PoolByCri@691085ec mcp=SemaphoreArrayListManagedConnectionPool@66a127f5[pool=HornetQConnectionDefinition] xaResource=XAResourceWrapperImpl@56a9bb4[xaResource=org.hornetq.ra.HornetQRAXAResource@4ca920eb pad=false overrideRmValue=null productName=HornetQ productVersion=2.0 jndiName=java:/JmsXA] txSync=null]
          at org.jboss.jca.core.connectionmanager.AbstractConnectionManager.reconnectManagedConnection(AbstractConnectionManager.java:780)
          at org.jboss.jca.core.connectionmanager.AbstractConnectionManager.allocateConnection(AbstractConnectionManager.java:518)
          at org.hornetq.ra.HornetQRASessionFactoryImpl.allocateConnection(HornetQRASessionFactoryImpl.java:948)
          ... 261 more
  Caused by: javax.resource.ResourceException: IJ000461: Could not enlist in transaction on entering meta-aware object
          at org.jboss.jca.core.connectionmanager.tx.TxConnectionManagerImpl.managedConnectionReconnected(TxConnectionManagerImpl.java:551)
          at org.jboss.jca.core.connectionmanager.AbstractConnectionManager.reconnectManagedConnection(AbstractConnectionManager.java:775)
          ... 263 more
  Caused by: javax.transaction.SystemException: IJ000356: Failed to enlist: java.lang.Throwable: Unabled to enlist resource, see the previous warnings. tx=TransactionImple &lt; ac, BasicAction: 0:ffff0a0001c3:682851c6:5900737b:dd09939 status: ActionStatus.ABORT_ONLY &gt;
          at org.jboss.jca.core.connectionmanager.listener.TxConnectionListener$TransactionSynchronization.checkEnlisted(TxConnectionListener.java:848)
          at org.jboss.jca.core.connectionmanager.listener.TxConnectionListener.enlist(TxConnectionListener.java:383)
          at org.jboss.jca.core.connectionmanager.tx.TxConnectionManagerImpl.managedConnectionReconnected(TxConnectionManagerImpl.java:544)
          ... 264 more
  </code></pre>
  
  <p>The reason why the transaction is in state ABORT_ONLY is a warning previously logged:</p>
  
  <pre><code>2017-05-30 11:33:15,977 WARN  [com.arjuna.ats.jta] (Thread-123) ARJUNA016086: TransactionImple.enlistResource setTransactionTimeout on XAResource &lt; formatId=131077, gtrid_length=29, bqual_length=36, tx_uid=0:ffff0a0001c3:-7a698606:591fe1ff:82cea51, node_name=1, branch_uid=0:ffff0a0001c3:-7a698606:591fe1ff:830e516, subordinatenodename=null, eis_name=java:/JmsXA &gt; threw: XAException.XAER_RMERR: javax.transaction.xa.XAException
  Caused by: HornetQConnectionTimedOutException[errorType=CONNECTION_TIMEDOUT message=HQ119014: Timed out waiting for response when sending packet 51]
         at org.hornetq.core.protocol.core.impl.ChannelImpl.sendBlocking(ChannelImpl.java:390)
         at org.hornetq.core.client.impl.ClientSessionImpl.start(ClientSessionImpl.java:1901)
  </code></pre>
  
  <p>Some details:</p>
  
  <ul>
  <li>The two packet types getting the timeout are 51 (<code>SESS_XA_START</code>) and 63 (<code>SESS_XA_SET_TIMEOUT</code>)</li>
  <li>The only other participant in the transaction is an Oracle XA connection </li>
  <li>There are 0 queues and 1 (durable) topic that messages are being consumed from (message count is at or just above 0) </li>
  </ul>
  
  <p>The messages are sent from a singleton EJB while the relevant business method is annotated with <code>@Lock(LockType.READ)</code>, so it can be called concurrently.
  The EJB injects the <code>java:/JmsXA</code> <code>TopicConnectionFactory</code> and the <code>Topic</code> and creates a new <code>TopicConnection</code>, <code>Session</code> and <code>MessageProducer</code> on each invocation of the method (each message being sent) and takes care to close all of them in a <code>finally {}</code> block.</p>
  
  <p>Since the timeouts occur sending packets 51 (<code>SESS_XA_START</code>) and 63 (<code>SESS_XA_SET_TIMEOUT</code>) it seems starting the session is slow or hangs.</p>
  
  <p>Any idea what the reason could be?</p>