1 Reply Latest reply on Mar 25, 2014 8:26 AM by Andy Taylor

    RuntimeException subclass annotated with @ApplicationException(rollback=false) still rolls back if

    John Francis Newbie

      I am using Jboss As 7.1.1.Final with Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)  under Windows 7


      I have a vanilla Message Driven Bean;


      @MessageDriven(name = "QTestAppExceptionMDB", activationConfig = {

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

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

        @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge") })


      public class QTestAppExceptionMDB implements MessageListener {


        private static int beans = 0;

        private int count = 0;

        private String id;


        DateTime now = DateTime.now();

        DateTimeFormatter fmt = DateTimeFormat.forPattern("k:m:s.SSS");

        id = "MDB (AppExceptioning) ID=" + ++beans + ", " + now.toString(fmt);




        public QTestAppExceptionMDB() throws JAXBException {



        public void onMessage(Message message) {


        System.err.println(id + ": count is " + count);



        throw new MyNonRollbackRuntimeException("This is a BL error: ");




        private void forwardMessage(Message message) {

        String destinationName = "queue/streamed";

        Context ic = null;

        ConnectionFactory cf = null;

        Connection connection = null;



        try {

        ic = new InitialContext();



        cf = (ConnectionFactory) ic.lookup("/JmsXA");

        Queue queue = (Queue) ic.lookup(destinationName);



        connection = cf.createConnection();

        Session session = connection.createSession(false,


        MessageProducer publisher = session.createProducer(queue);







        } catch (Exception exc) {


        } finally {



        if (connection != null) {

        try {


        } catch (JMSException e) {








      MyNonRollbackRuntimeException is a RuntimeException which is marked as an Application Exception,

      with rollback=false;



      public class MyNonRollbackRuntimeException extends RuntimeException {



        public MyNonRollbackRuntimeException(String arg0) {





      When I run the example the message forwarded by forwardMessage is not seen by the 'downstream' message listener.

      If I comment out the throw of MyNonRollbackRuntimeException, it is.

      So I assume despite the fact that my RuntimeException is marked as rollback=false, the transaction is being rolledback.

      HornetMQ goes into its normal resubmission protocol, and I see the message being resubmitted as if it had been rolledback.

      There is a difference between the behaviour of MyNonRollbackRuntimeException and a normal RuntimeException which is that the MDB instance is not discarded if the MyNonRollbackRuntimeException is thrown.


      Looking at;




      p 213 Table 12 in the section 9.3.4 Exceptions from Message-Driven Bean Message Listener Methods, it might appear that I should expect the transaction to commit, but it is not clear.


      Do the HornetMQ maintainers think this is a bug, or is it just badly defined by the specs (or is there another spec I missed) and therefore up to the implementers?





      Moved to AS forum  https://community.jboss.org/thread/238424