How does Setsessiontransacted work in JMSTemplate and DefaultMessageListenerContainer with Pub/sub model

2k Views Asked by At

I am using a publisher/subscriber model in which I am using JMSTemplate to publish messages onto a topic. I am using defaultmessagelistenercontainer to subscribe and receive messages.

I know I can I set sessionTransacted true in both the configurations. But what happens if I put

1) only JMSTemplate setsessionTransacted true?

2) only messagelistenercontainer setsessiontransacted true?

3) both JMSTemplate and messagelistenercontainer setsessiontransacted true?

I just want to know the difference between each of these 3 things in terms of message being sent to topic and subscriber receiving the message and performing the required work with it. My core question I am trying to understand is

How long does the session last in covering these things?

message being sent to topic and subscriber receiving the message and performing the required work with it

1

There are 1 best solutions below

4
On

The transactions are separate. The consumer doesn't get the message until the send is committed.

If you consume a message and send another on the same thread, and both are transacted, they will both run in the same tranaaction.