Reputation: 57
I have a spring application with a consumer to consume messages and write them to a database. I'm using the spring DefaultMessageListenerContainer. Is there a way to consume a message and upon a database exception being thrown put the message back onto the queue?
Upvotes: 0
Views: 1043
Reputation: 174759
setSessionTransacted(true)
If you are using the namespace to configure the container, use
<jms:listener-container acknowledge="transacted" ...>
<jms:listener ... />
</jms:listener-container>
You also might want to synchronize the database and JMS transactions by adding the JDBC transaction manager to the container configuration.
See Dave Syer's Javaworld Article about Distributed transactions in Spring, with and without XA
Upvotes: 1