BEA Systems, Inc.

WebLogic Server 8.1 API Reference

Interface MDBTransaction

public interface MDBTransaction

JMS extension to associate a message delivered to a MDB (message-driven bean) with a transaction.

Note: As of WebLogic Server release 7.0, MDBs support transactions for foreign JMS vendors that do not implement this interface.

Copyright © 2004 BEA Systems, Inc. All Rights Reserved.

Method Summary
 void associateTransaction(javax.jms.Message message)
          This method infects an unacknowledged, non-transactional message with the current transaction.

Method Detail


public void associateTransaction(javax.jms.Message message)
                          throws javax.jms.JMSException
This method infects an unacknowledged, non-transactional message with the current transaction. It is intended for use by transactional MDB containers, and is not for use by non-transactional MBeans!

The container must use sessions created with the Session.CLIENT_ACKNOWLEDGE acknowledge mode, and must not call "acknowledge" directly. The container must use only one consumer per session. Since JMS schedules onMessage calls in their own thread, the container does not need to do this.

The MDB container should look similar to this:

   import weblogic.jms.extension.MDBTransaction;
   class MBeanContainer
     implements MessageListener

     void onMessage(Message message) {
       // container may have a utx pool or create a new tran on the spot
       UserTransaction utx = allocateTransaction();

       utx.begin();   // may throw exception

       // may throw exception

       // pass message to client in same thread as utx.begin() call
       // so that it gets infected.
       on success
         utx.commit();   // may throw exception
       on failure
         utx.rollback(); // may throw exception
       // return utx to pool

message - javax.jms.Message
javax.jms.JMSException - if a JMS error occurs

Documentation is available at