Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return value of enlistResource is ignored #32

Closed
renebos99 opened this issue Oct 16, 2023 · 1 comment
Closed

Return value of enlistResource is ignored #32

renebos99 opened this issue Oct 16, 2023 · 1 comment

Comments

@renebos99
Copy link

In the class org.messaginghub.pooled.jms.pool.PooledXAConnection, the method enlistResource of TransactionManager is invoked, but the return value of this method is ignored. The return value is a boolean; accoriding to the spec, it is true if the resource was enlisted, and false otherwise.
We are using the PooledXAConnection in combination with the Narayana transaction manager (org.jboss.narayana.jta:narayana-jta:5.12.7.Final). This implementation sometimes returns false for enlistResource if a resource is not available (in such a case, the transaction is marked as rollback-only). Since this return value is not checked, the processing continues despite the absence of a working transaction. In our case, this has lead to situations where messages could not be processed and were lost.

It would be good to check the return value of enlistResource, and perform appropriate actions if the return value is false.

Stack trace, in case it can be useful:

ARJUNA016061: TransactionImple.enlistResource - XAResource.start returned: XAException.XAER_RMFAIL for < formatId=131077, gtrid_length=50, bqual_length=36, tx_uid=0:ffffac1edcbf:-3c0b9c4d:651eb4d8:225e2, node_name=grnapj0080linprdduonl8, branch_uid=0:ffffac1edcbf:-3c0b9c4d:651eb4d8:225e6, subordinatenodename=null, eis_name=unknown eis name >: javax.transaction.xa.XAException: The method 'xa_start' has failed with errorCode '-7'.
	at com.ibm.mq.jmqi.JmqiXAResource.start(JmqiXAResource.java:1019)
	at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.enlistResource(TransactionImple.java:661)
	at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.enlistResource(TransactionImple.java:422)
	at org.messaginghub.pooled.jms.pool.PooledXAConnection.createSession(PooledXAConnection.java:72)
	at org.messaginghub.pooled.jms.JmsPoolConnection.createSession(JmsPoolConnection.java:194)
	at org.springframework.jms.support.JmsAccessor.createSession(JmsAccessor.java:214)
	at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.access$200(AbstractPollingMessageListenerContainer.java:78)
	at org.springframework.jms.listener.AbstractPollingMessageListenerContainer$MessageListenerContainerResourceFactory.createSession(AbstractPollingMessageListenerContainer.java:509)
	at org.springframework.jms.connection.ConnectionFactoryUtils.doGetTransactionalSession(ConnectionFactoryUtils.java:328)
	at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:294)
	at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:246)
	at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1237)
	at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:1227)
	at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:1120)
	at java.lang.Thread.run(Thread.java:750)
@tabish121
Copy link
Contributor

My general advice would be not to mix XA connection work and a connection pool.

tabish121 added a commit that referenced this issue Nov 17, 2023
If the TXN manager does not enlist the XASession into the TXN then we
should throw an error to indicate that the session could not enter the
TXN and we need to ensure that on an error in enlistment or in
registering the synchronization we return the session to the pool and
properly reset the connection references so that session don't get
trapped in the loaned state.

This closes #32

(cherry picked from commit c79b2b3)
tabish121 added a commit that referenced this issue Feb 15, 2024
If the TXN manager does not enlist the XASession into the TXN then we
should throw an error to indicate that the session could not enter the
TXN and we need to ensure that on an error in enlistment or in
registering the synchronization we return the session to the pool and
properly reset the connection references so that session don't get
trapped in the loaned state.

This closes #32

(cherry picked from commit c79b2b3)
(cherry picked from commit 77cda3a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants