Results 1 to 4 of 4

Thread: Best efforts 1 PC pattern with SI AMQP support available?

  1. #1
    Join Date
    Aug 2004
    Posts
    14

    Default 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
    --og

  2. #2
    Join Date
    Jun 2005
    Posts
    4,230

    Default

    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.

  3. #3
    Join Date
    Aug 2004
    Posts
    14

    Default

    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
    --og

  4. #4
    Join Date
    Jun 2005
    Posts
    4,230

    Default

    Quote 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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •