Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between sessionTransacted and JmsTransactionManager

What is the main difference between using sessionTransacted=true (in JmsTemplate and/or DefaultMessageListenerContainer) and using JmsTransactionManager? Is using sessionTransacted=true enough for both JmsTemplate and DefaultMessageListenerContainer usages? (I don't need XA)

The doc said (in setSessionTransacted method in JmsAccessor), and it seems that shouldn't be a problem:

Setting this flag to "true" will use a short local JMS transaction when running outside of a managed transaction, and a synchronized local JMS transaction in case of a managed transaction (other than an XA transaction) being present.

like image 895
Arya Avatar asked May 23 '14 18:05

Arya


2 Answers

Correct.

On the DefaultMessageListenerContainer(DMLC) you typically only need acknowledgemode=transacted; you would only use a transaction manager on a DMLC if you need to synchronize the JMS transaction with, say, a JDBC transaction or you need to use a platform (JTA) transaction manager.

Further, any downstream JmsTemplate operation on the container's thread will be done in the same session and participate in the transaction.

Similarly, for JmsTemplate operations on a thread that is not a container thread you generally don't need a transaction manager, unless the platform requires it.

like image 129
Gary Russell Avatar answered Sep 22 '22 00:09

Gary Russell


session transactioned means transaction start when session start, transaction end when session end.if you need more control on the transaction you need JmsTransactionManager (local)

like image 1
Andrew Avatar answered Sep 22 '22 00:09

Andrew