4

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

africandrogba
  • 334
  • 1
  • 3
  • 21

1 Answers1

0

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.

Gary Russell
  • 166,535
  • 14
  • 146
  • 179
  • So from what I understood jmsTemplate and DMLC transactions are separate. – africandrogba Sep 19 '17 at 20:40
  • So from what I understood, jmsTemplate and DMLC transactions are separate. So if my DMLC sessiontransaction is set to true, all the code in the onMessage() method will be done within a transaction. What happens if there was an exception in my onMessage(). Will the message be resent to my listener and the execution happens again? – africandrogba Sep 19 '17 at 20:47
  • I am using a Topic not a queue – africandrogba Sep 19 '17 at 20:52
  • Topic Vs. Queue is irrelevant. The message is rolled back and redelivered. Indefinitely unless your broker supports dead lettering poison messages. Some brokers provide a redelivery count header. – Gary Russell Sep 19 '17 at 21:10