3

I was reading about (and have sample implemented) JMS Topic Subscribers on Tibco MoM. These are the links that I am referring to : Link1

However, I was not clear about how the transaction is going to be managed over multiple subscribers. I am using DefaultMessageListenerContainer as the Container and a durable Subscription.

Typically, when the onMessage of a subscriber completes, the transaction is committed. How does it happen over multiple subscribers?

Now, suppose Subscriber1 received the message and processed an action based on it (The action cannot be reversed). Later Subscriber2 came alive and tried to process this message. Something went wrong and now the transaction has to be rolled back - Message will be put back in the Topic.

Next, will the Subscriber1 see the Message again? Will it have to consume the message again? Is this a case of distributed transactions? When does commit happen?

TJ-
  • 14,085
  • 12
  • 59
  • 90

1 Answers1

2

Each subscriber receives its messages in its own transaction, and provided the transaction commits successfully, the individual subscriber will not see that message again. On a subscriber transaction rollback,the message will be redelivered to the failing subscriber only (assuming the broker is not limiting redeliveries).

Nicholas
  • 15,916
  • 4
  • 42
  • 66
  • Thanks Nicholas. When is the message removed from the Topic? What mechanism is used to track that? Typically in a Queue, the message is removed as soon as a consumer Listener commits the 'consume/onMessage' transaction. – TJ- Feb 14 '13 at 13:32
  • 1
    The broker is responsible for retaining the message until it has been delivered to all connected non-durable subscribers and all durable subscribers subscribed at the time the message was published. Different implementations vary on exactly how this is accomplished, and if the message has a time-to-live specified, the broker may discard the message once it is expired, regardless of whether or not it has been received by all subscribers. – Nicholas Feb 14 '13 at 14:00