1 2 3 Previous Next 31 Replies Latest reply on Jan 16, 2012 3:22 AM by Markus Döring

    JMS transacted messages not working?

    Markus Döring Newbie

      Hello,

       

      I'm using JBoss AS 7.1.0.CR1, but had this issue on JBoss AS 7.0.1 (Full Profile).

       

      I have the following Stateless Session Bean:

      @Stateless
      public class TestBean implements TestService {
      
           @Resource(mappedName = "java:/ConnectionFactory")
           private ConnectionFactory connectionFactory;
      
           @Resource(name = "TestQueue", mappedName = "java:jboss/queue/TestQueue")
           private Queue testQueue;
      
           @TransactionAttribute(TransactionAttributeType.REQUIRED)
           public void sendMessage(Serializable message) {
                Connection connection;
                Session session;
                try {
                     connection = connectionFactory.createConnection();
                     session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
                     MessageProducer producer = session.createProducer(testQueue);
                     connection.start();
                     ObjectMessage message = session.createObjectMessage(message);
                     producer.send(objectMessage);
                } catch (Throwable thr) {
                     Logger.getLogger(TestBean.class).error("Error sending message.", thr);
                } finally {
                     if(session != null) {
                          session.close();
                     }
                     if(connection != null) {
                          connection.close();
                     }
                }
           }     
      }
      
      
      
      
      
      
      
      

       

      And the following Message Driven Bean:

       

      @MessageDriven(
           name="TestMDB",
           activationConfig = {
                @ActivationConfigProperty(propertyName="acknowledgeMode", propertyValue="auto_acknowledge"),
                @ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Queue"),
                @ActivationConfigProperty(propertyName="destination", propertyValue="queue/TestQueue"),
                @ActivationConfigProperty(propertyName="maxSession", propertyValue="1")
           }
      public class TestMDB implements MessageListener {
           public void onMessage() {
                Logger.getLogger(TestMDB.class).debug("onMessage");
           }
      }
      

       

      All of this is working perfectly, but i want the message to be added to the queue after transaction commit.

      So i change the following lines:

       

      from
                     session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
      to
                     session = connection.createSession(true, Session.SESSION_TRANSACTED);
      
      and
      from
                @ActivationConfigProperty(propertyName="acknowledgeMode", propertyValue="auto_acknowledge"),
      to
                @ActivationConfigProperty(propertyName="acknowledgeMode", propertyValue="session_transacted"),
      

      (worked like this on JBoss 4.2.2)

       

      after this, the message is never commited to the queue and so the MDB never recives something.

      Anything I'm doing wrong?

      Or is this still a bug in CR1?

      Can't find anything on JIRA.

       

      Thanks

      Markus

        1 2 3 Previous Next