Arya
Arya

Reputation: 3029

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.

Upvotes: 6

Views: 10244

Answers (2)

Gary Russell
Gary Russell

Reputation: 174544

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.

Upvotes: 4

Andrew
Andrew

Reputation: 876

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)

Upvotes: 2

Related Questions