Topic messages are not sent when using transacted JmsTemplate in 'TransactionSynchronization.afterCommit' phase [SPR-16270] #20817
On the following scenario, an attempt to send message to a TOPIC using JmsTemplate is not effective (the message is never sent and there is no error):
The expectation is that the message would be send and the subscriber would handle it.
It appears that Spring determines the existence of an ongoing transaction by checking state
Since the 'synchronizations' thread local is not cleared when executing the 'afterCommit' callback, Spring mistakenly assumes that there is ongoing transaction and hence bounds the JMS operation to the ongoing transaction (instead of commiting it immediately) and since there is no ongoing transaction the JMS operation would never be committed.
The text was updated successfully, but these errors were encountered:
Juergen Hoeller commented
While I agree that this behavior is unintuitive, it is actually documented in the
That said, we should be doing something to make this more obvious: maybe logging a warning for newly created resources at that point, or even outright rejection of new resource creation after the managed transaction commit.