Sep 4th, 2011, 09:53 AM
Best efforts 1 PC pattern with SI AMQP support available?
what is the recommended way to implement a best efforts 1 PC pattern with SI AMQP and a JDBC datasource?
David Syer has described this pattern in the following link: http://www.javaworld.com/javaworld/j...ns.html?page=5
The recommended way for JMS and a database is to use the JMS TransactionAwareConnectionFactoryProxy which will synchronize with the DataSourceTransactionManager.
Because the Spring RabbitMQ support tries to mirror the JMS support I've searched for a AMQP TransactionAwareConnectionFactoryProxy but I do not have found one!?
There is the AMQP RabbitTransactionManager which implements a "local" transaction on it's own but this does not solve our problem with DB transaction synchronization!
Any info if there is some hidden support elsewhere or a workaround / different strategy would be helpful.
Thanks and greetings.
Sep 6th, 2011, 03:41 PM
TransactionAwareConnectionFactoryProxy is actually not usually the best way to get Best Efforts 1PC in Spring JMS, at least if your consumer is asynchronous. Is your consumer asynchronous (<rabbit:message-listener-container/>)? If so then BE1PC is achieved by using a DataSourceTransactionManager and setting channelTransacted=true and acknowledgeMode=AUTO on the message listener container. If you are rolling your own synchronous consumer then you just need channelTransacted=true in your RabbitTemplate and to wrap the call to receive() in a DataSource transaction using normal Spring transaction features.
Sep 7th, 2011, 04:59 PM
as far as I understand this solvers this use-case:
receive message -> write to DB
Or as BE1PC
But what about the following use case?
Write a log message to DB and send a message to RabbitMQ
In this use case the message is the "inner" TX in the BE1PC strategy:
I assume I should use the RabbitTransactionManager in this case, right?
But what to use for the DB synchronization? Does there exists an out-of-the-box solution in the spring framework?
Sep 8th, 2011, 08:11 AM
No, you use the settings I suggested, the AMQP transaction will be synchronized with the database transaction if one is in flight.
Originally Posted by ogeisser