2 Replies Latest reply on Dec 18, 2002 2:57 AM by lion78at

    Use transactional JMS in JBoss

    lion78at

      Hello!

      I want to do this:

      Read some datasets from database and send each dataset to a queue. If there occurs an error, then the whole transaction (= sending messages) should be rolled back.

      The container should take care of controlling the transaction. This means: I configure the corresponding method as "transaction=required" and the rest should be done by container! If an error occurs I throw an EJBException and so the whole transaction will be rolled back by container.

      My question: How can I do this?

      I tried already XAConnectionFactory, createQueueSession(true,0), ... but this doesn't seems to work in this way.

      Thanks for answears, best regards, Bernhard.

        • 2. Re: Use transactional JMS in JBoss
          lion78at

          Hello Adrian!

          Many thanks, this hint helps me a lot!

          Just one more question. This is my source now (which works):

          InitialContext ictxBean=new InitialContext();

          QueueConnectionFactory qcnfcMessaging=(QueueConnectionFactory)ictxBean.lookup("java:/JmsXA");
          QueueConnection qcnMessaging=qcnfcMessaging.createQueueConnection();
          QueueSession qsesMessaging=qsesMessaging=qcnMessaging.createQueueSession(true,0);
          QueueSender qsenMessaging=qsesMessaging.createSender(null);

          ObjectMessage omMessaging=qsesMessaging.createObjectMessage();
          omMessaging.setObject(serObject);

          Queue queMessaging=(Queue)ictxBean.lookup("java:comp/env/jms/myQueue");
          qsenMessaging.send(queMessaging,omMessaging);

          qsenMessaging.close();
          qsesMessaging.close();
          qcnMessaging.close();


          Is this right now? Am I right, that the parameters of createQueueSession(...) are equal?

          Regards, Bernhard.