7 Replies Latest reply on Aug 3, 2009 4:49 AM by Andy Taylor

    Transaction management in JCA adapter is screwed up

    Tim Fox Master

      I just took a look at the tx management code in the JCA adapter, and it looks just plain wrong in places.

      JBMMessageHandler::onMessage.

      Firstly it seems a transaction is *always* being started and committed/rolled back for *every* message. It's my understanding that this should only be done if the bean is using CMT and the transaction atttribute is Required.

      For BMT or transaction attribute=NOT_SUPPORTED no transaction should be created.

      Also

       if (activation.getActivationSpec().getAcknowledgeModeInt() == Session.SESSION_TRANSACTED || activation.getActivationSpec()
       .getAcknowledgeModeInt() == Session.CLIENT_ACKNOWLEDGE)
       {
       try
       {
       message.acknowledge();
       }
       catch (MessagingException e)
       {
       log.error("Failed to process message", e);
       }
       }
      


      The above code is a nonsense, since a) it's illegal to use CLIENT_ACKNOWLEDGE in a MDB and b) if a session is transacted, message.acknowledge() does nothing anyway.

      Also the code in JBMResourceAdapter::createSession seems just plain wrong - it seems to be creating XA sessions when ack mode = auto_ack !! ??

      The specification "EJB core contracts and requirements" Chapter 5 should be read properly and the code in the adapter corrected.