Consuming Messages in Transactions

To consume messages in transactions, a client must acquire a MessageConsumer or TopicSubscriber from the transacted Session.

After acquiring a MessageConsumer or TopicSubscriber, messages can then be received either:

  • asynchronously, through a defined MessageListener
  • synchronously, through individual receive(...) calls

Consumers in a transacted Session function the same as those in a non‑transacted Session, except that the messages they receive are only acknowledged, and subsequently removed from the event broker, when a successful commit occurs for the transacted Session. For example, calling Message.acknowledge() has no effect on transacted Sessions. For information on how to receive Guaranteed messages synchronously or asynchronously through a MessageConsumer, refer to Receiving Messages Synchronously or Asynchronously.

When the following situations occur after the messages are consumed in a transaction, but before a commit is made, those messages are still successfully committed:

  • The messages are removed from the event broker by an administrative action (that is, the messages are deleted from the spool).
  • The amount of time set for the messages’ TTL has expired. The commit succeeds whether or not expired messages are moved to a Dead Message Queue (DMQ).