Question

I have a question regarding JMS and Spring Integration.

I have 3 queues, let's call them QUEUE_SOURCE, QUEUE_TARGET and QUEUE_ERROR. A DefaultMessageListenerContainer is used to read the messages from the QUEUE_SOURCE.

I have configured a JMS Transaction manager for these queues.

When I read from the QUEUE_SOURCE, but an error occurs when posting the message to QUEUE_TARGET, I can see that the message is retried a few times before an exception is thrown, triggering a rollback.

I guess what happens is this:

1) Start transaction 2) Read message 3) Try to post message on target queue QUEUE_TARGET, but fail 4) Do not commit because of error, so message is not removed from QUEUE_SOURCE

OR

1) Start transaction 2) Read message 3) Remove message from QUEUE_SOURCE 4) Try to post message on target queue QUEUE_TARGET, but fail 5) Put message back on QUEUE_SOURCE

After all redeliveries fail, a rollback is triggered.

However, what happens during this rollback confuses me. I have no clue where the message ends up, it certainly does not end up on the source queue, and it does not end up on the error queue either. So what is really happening during this rollback?

Was it helpful?

Solution

You would need to show your exact configuration but your speculation #1 is close; the broker delivers the message but does not remove it from the queue until the commit. If your code throws and exception, the framework will execute session.rollback() and the broker will redeliver. If the delivery is successful, the framework will commit the transaction and only then will the message be removed.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top