Skip to content

Send of message via tx-channel is commited early when external (JTA) transaction is present [AMQP-479] #2036

@spring-operator

Description

@spring-operator

Norbert Wirges opened AMQP-479 and commented

When an external JTA/EJB transaction calls a transactional spring bean (using JtaTransactionManager), which in turn sends a RabbitMQ-message (using RabbitTemplate), then the message is committed on the channel when the spring transaction bracket ends (not as expected when the outer JTA transaction is committed).

This StackOverflow question describes the same problem:
http://stackoverflow.com/questions/25773000/spring-amqp-rabbitmq-transaction-rollback-in-ejb3-cmt

The reason seems to be, that AbstractPlatformTransactionManager.processCommit() executes onCommit() callbacks immediately (whereas afterCompletion-Callbacks are passed on to a surrounding transaction). As the RabbitTemplate uses onCommit() callbacks (see RabbitResourceSynchronization) this causes the described behavior.
Moving the channel commit to afterCompletion in RabbitResourceSynchronization should fix this problem.


Affects: 1.3.8, 1.4.3

Reference URL: http://stackoverflow.com/questions/25773000/spring-amqp-rabbitmq-transaction-rollback-in-ejb3-cmt

Referenced from: pull request #340

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions