Hello.
I'm trying to understand how JmsTemplate bean can take part in JTA Global transaction. In JmsTemplate.java from org.springframework.org.jms.core package I found two places with session.commit() :
at line 608 (in doSend() code):
and at line 727 (in doReceive() code):Code:if (session.getTransacted() && !TransactionSynchronizationManager.hasResource(getConnectionFactory())) { // transacted session created by this template -> commit session.commit(); }
For session created in JTA transaction session.getTransacted() returns true, at least for JORAM and ActiveMQ implementation of XASession.Code:if (session.getTransacted()) { if (conHolder == null) { // transacted session created by this template -> commit session.commit(); } }
For second condition in first snippet TransactionSynchronizationManager.bindResource() should be called somewhere, but JtaTransactionManager have no such call.
As a result when I'm trying to use JMS XA-aware ConnectionFactory/Connection/Session (slightly modified JONAS JConnectionFactory/JConnection/JSession) with JtaTransactionManager, i'm getting exceptionfrom JSession.Code:"XASession: commit not allowed"
I'm tried to make call to TransactionSynchronizationManager.bindResource(myC onnectionFactory, null) before starting JMS&JTA - it works for doSend(), but does not prevent commit in doReceive().
On the other hand TransactionSynchronizationManager.bindResource(myC onnectionFactory, new ConnectionHolder(null, null)) - can work with doReceive(), but not with doSend().![]()
Can someone show the solution for this issue ?
Regards, Igor


Reply With Quote