Results 1 to 5 of 5

Thread: Spring AMQP Transactions on Send / Template

  1. #1
    Join Date
    Feb 2012
    Location
    Honolulu, HI
    Posts
    4

    Default Spring AMQP Transactions on Send / Template

    Hello,

    I am using the 20120213 build of 1.0.1 so that I don't have leaking channels. I want to do something like this (amqpTemplate has channel-transacted="true"):

    Code:
    @Transactional
    public void test() {
      for(int i=0; i < 10; i++) {
        // some database add's are happening here...
        amqpTemplate.convertAndSend("TEST");
        // this allows me to watch the queue in the RabbitMQ admin
        try { Thread.sleep(15000); } catch (InterruptedException e) { ; }
      }
      String test = null;
      if(test.endsWith("test")) { ; }
    }
    As you can see the code loops 10 times and tries to send a message every 15 seconds. I'm expecting not to see the messages in the queue because at the end a NullPointerException is thrown and the transaction should roll back. I see all 10 messages, 1 appearing every 15 seconds, and they don't roll back. Is this the expected behavior or is this a bug?

    Thanks so much,
    Jason

  2. #2
    Join Date
    Feb 2012
    Location
    Honolulu, HI
    Posts
    4

    Default

    BTW: this behavior is also observed in the 1.0.0 release with the addition of leaking channels. Can anyone tell me if this is the expected behavior? Rollbacks seem to work flawless on the Listener side.

  3. #3
    Join Date
    Jun 2005
    Posts
    4,232

    Default

    If you can show the stack trace from your exception we can see if there is actually a transaction in flight. What transaction manager are you using?

    Aside: note that 150sec for a transaction is pretty long and longer than most people or transactional resources would tolerate out of the box. I don't think that's the problem here because you are not seeing a rollback.

  4. #4
    Join Date
    Feb 2012
    Location
    Honolulu, HI
    Posts
    4

    Default

    Dave, thank you very much for the response. I am having some very strange issues with my transaction annotations where some are working flawless and in the same context some aren't. I have to track it down before I can see if it's working with amqp. I will let you know how it turns out.

    BTW: i'm using org.springframework.orm.hibernate3.HibernateTransa ctionManager....

  5. #5
    Join Date
    Feb 2012
    Location
    Honolulu, HI
    Posts
    4

    Default

    Dave, this was a false alarm. I have transactions working very well now. I had a non-annotated method call an annotated method in the same class. the outer non-annotated class was catching exceptions. somehow that was causing the transactions to commit.... if i moved the outer method out of the class and into another, then the transactions would roll back.... spring is, somehow, making the outer method transactional when both methods are in the same class. i guess this has to do with the proxies. i was pulling my hair out.

Posting Permissions

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