Announcement Announcement Module
Collapse
No announcement yet.
Best efforts 1 PC pattern with SI AMQP support available? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Best efforts 1 PC pattern with SI AMQP support available?

    Hi there,

    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.

    Olli

  • #2
    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.

    Comment


    • #3
      Thanks Dave,

      as far as I understand this solvers this use-case:

      receive message -> write to DB

      Or as BE1PC

      receive message
      write DB
      commit DB
      ACK message


      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:

      write DB
      send message
      commit message
      commit DB

      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?

      Thanks
      Olli

      Comment


      • #4
        Originally posted by ogeisser View Post
        I assume I should use the RabbitTransactionManager in this case, right?
        No, you use the settings I suggested, the AMQP transaction will be synchronized with the database transaction if one is in flight.

        Comment

        Working...
        X