1 Reply Latest reply: Jul 23, 2012 12:23 PM by Tom B RSS

    JMS and Container managed transactions

      I'm running weblogic 10.3.4 with a JMS producer/consumer, Oracle database. The EJBs are annotated to configure the container managed transactions. The server is functioning almost as I expect.

      Some background info: I have a single threaded producer that runs periodically and generates a large number of messages that are sent to the consumer.

      The one problem I am having is I cannot determine how to tell the JMS producer to commit the message. I would like to commit the message to the queue after each sendMessage call since the message can be consumed as the rest of the messages are being generated. However, the application seems to hold on to the messages until the generateMessage function is complete and returns. Thus after generateMessages completes (and I assume commit is called at this point), my consumers start processing the messages.

      How can I tell the application to commit the message to the queue immediately after sendMessage is called?

      public generateMessages(...)
      List dataList= msgDAO.query();
      for (Data data : dataList)
      Mesage message = createMessage(data);

      private sendMessage(...)
      producer = session.createProducer(destination);
      TextMessage msg = createQueueTextMessage(session, properties, message,

      I've read the documentation here:

      It looks like a new transaction is started and then "Delegates the call to the method"
        • 1. Re: JMS and Container managed transactions
          Tom B

          I think you have a few options:

          - Suspend the XA transaction before calling send and then resume it just after:

          - Put the "send()" call in a separate stateless EJB method that's annotated with TransactionAttributeType.NOT_SUPPORTED. (I think this particular annotation causes a suspend/resume.)

          - Configure and use a custom WL JMS connection factory that has "XA enabled" set to false. Any JMS producer or consumers that are created with this CF will not participate in XA transactions.