0 Replies Latest reply on Oct 23, 2009 10:02 AM by Jeff Mesnil

    JMS transaction failover example

    Jeff Mesnil Master

      I am adding examples showing how failover works now.

      The first example is using a JMS transacted session.
      At first, I killed the server while no work was done in the in-flight transaction
      => in that case, the failover should be transparent
      Then I killed the server while I have received messages during the transaction
      => when I commit the session, it should fail as the tx is flagged as rollback only
      and I can retry to receive messages

      The fist case (failover with no work done in the in-flight transaction) did not work at first.
      The consumer is created and the session started before the failover. When messages are sent,
      they are delivered to the consumer's buffer.
      When the failover occured, the messages were kept in the buffer and the client received them.
      But these messages correspond to deliveries from the live server and could not be acked on the backup server.

      I added a call to ClientConsumer.clearAtFailover() in ClientSessionImpl.handleFailover() to clear the
      consumer's buffer and make it work.
      This way, the consumer has no deliveries from the crashed live server kept in its buffer after failover and is delivered
      the messages from the backup server as expected.

      My second issue is when I crash the server after receiving messages and before commit:

      1. create JMS consumer
      2. start JMS session
      3. send messages
      4. commit the JMS session
      5. receive messages from the JMS consumer
      6. crash the live server
      7. commit the session
       => I was expecting an exception but the commit passed silently

      The issue I have is that the JMS messages received at #5 were delivered to the ClientSession before the commit at step #4.
      When a new transaction is started at step #5, no work is done from the ClientSession POV. The session will then commit the transaction
      at step #7 without any problem.
      When I receive messages after step #7, I will receive again the messages but they are not flagged as JMSRedelivered

      AIUI, using transacted session when failover occurs should preserve once and only once delivery guarantee but that's not the case here.