1 Reply Latest reply on May 15, 2014 4:25 AM by c.keimel

    MDB with Bean Managed Transaction

    kr8670

      Hi,

       

      I've got a MDB basically layed out as the following (as7 build from a couple of days ago):

       

      @MessageDriven(activationConfig = {

          @ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Queue"),

          @ActivationConfigProperty(propertyName="destination", propertyValue="queue/A"),

          @ActivationConfigProperty(propertyName="messageSelector", propertyValue="source = 'IDA' AND type='Edit'")

      })

      @TransactionManagement(TransactionManagementType.BEAN)

      public class SomeMDB implements MessageListener {

         

          @Inject

          private Logger log;

         

          @PersistenceContext

          private EntityManager em;

         

          @Resource

          private EJBContext ctx;

       

          public void onMessage(Message msg) {

                try {

                     final UserTransaction tx = ctx.getUserTransaction();  // <-- Error here

                     Session session = (Session)em.getDelegate();

                     tx.begin();

                     // do stuff

                     tx.commit();

                } catch (Exception ex) {

                     log.error(ex);

                }

          }

      }

       

      I get this error when run:  javax.transaction.NotSupportedException: BaseTransaction.checkTransactionState - thread is already associated with a transaction!

       

      Is this a bug, not implemented, or something I've overlooked? It works fine in previous versions of JBoss.

       

      Regards

      Kjell