2 Replies Latest reply on Sep 24, 2002 7:59 PM by Elias Ross

    JMS with MDB/container-managed TX works?

    Elias Ross Master


      I've gotten MDB to work correctly with rolling-back
      the database when I call mdc.setRollbackOnly().

      However, I don't know how to create a QueueSession/Sender
      which will send its messages after the onMessage() method
      exists.

      I have bought the JBoss documentation, but it does not have
      an example of this case specifically. I suspect (but do not know)
      that JBoss does not support automatic QueueSession
      commit after an MDB exits its onMessage method.

      Does anyone have an example of this sending out messages:

      public class MessageDrivenBean implements MessageListener {

      // Container-managed transactions with Required
      // transaction attribute
      public void onMessage(...) {
      try {
      QueueConnection qc = qcf.createQueueConnection();
      QueueSession qs = qc.createQueueSession(true, 0);
      QueueSender qsend = qs.createQueueSender("queue/A");
      TextMessage m = qs.createTextMessage();
      m.setText("test");
      qsend.send(m);
      /*
      qs.close(); // JMS javadoc says this rollbacks
      // In any case, doesn't seem to work
      */
      qc.close();
      } catch (Exception e) {
      e.printStackTrace();
      }
      }

      }