Publishing Messages in Transactions in the PubSub+ JCSMP API
To publish Guaranteed messages in a transaction, a producer flow must first be established in the transacted session. For the PubSub+ JCSMP API, the client application must acquire an XMLMessageProducer
from the transacted session.
After establishing a producer flow, you can publish Guaranteed messages through the XMLMessageProducer.send(...)
method.
In a transaction, the event broker stages the published messages, and they are not delivered to their destinations on the event broker until the client issues a commit. A successful commit will deliver the messages to their destinations and remove the staging information.
How Endpoints’ Message Discard Behavior Affects Transactions
When a message published in a transaction cannot be successfully spooled to any of its destination endpoints on a commit, the message is discarded. In this case, whether or not the commit is successful depends on the endpoint’s message discard behavior property, which determines how the endpoint handles a discarded message.
If the message discard behavior property for the endpoint is not enabled, the message is ‘silently’ discarded, that is, the endpoint discards the message but returns a commit success response to the client, and the commit completes. In this case, the message can be spooled to other endpoints that it may have been destined for.
When provisioning a queue, by default the message discard behavior property is enabled; when provisioning a topic endpoint, by default the property is not enabled.
For information on the message discard behavior endpoint property and the conditions that can cause an endpoint to not spool and then discard a message, refer to Defining Endpoint Properties in the PubSub+ JCSMP API.