6 Replies Latest reply on Aug 2, 2002 2:21 PM by philc

    JMS publish roll-back

    donahuept

      Is there a way to "roll-back" what you publish so that subscribers do not see the message until you commit (similar to a database commit or roll-back)?

        • 1. Re: JMS publish roll-back
          hchirino

          Yes.. read the JMS spec.

          • 2. Re: JMS publish roll-back
            mkotsbak

            How would that be configured in J2EE/jboss? Is it an option, or is it like this as default? Are the messages not accessible by readers of the queue before commit then (like DB-transactions)?

            • 3. Re: JMS publish roll-back
              hchirino

              that is a standard JMS feature. Read the jms spec or hit the jms tutorial: http://java.sun.com/products/jms/tutorial/1_3_1-fcs/doc/jms_tutorialTOC.html

              • 4. Re: JMS publish roll-back
                donahuept

                Here is how:

                To start with, the first (transaction) parameter of your createTopicSession call should be "true" as in:
                topicSession = topicConnection.createTopicSession(true,Session.AUTO_ACKNOWLEDGE);

                Later you commit or rollback the transaction:
                topicSession.commit();
                topicSession.rollback();

                Reader of queue will not see the message until the commit just like a DB.

                • 5. Re: JMS publish roll-back
                  mkotsbak

                  > Here is how:
                  >
                  > To start with, the first (transaction) parameter of
                  > your createTopicSession call should be "true" as in:
                  > topicSession =
                  > topicConnection.createTopicSession(true,Session.AUTO_A
                  > KNOWLEDGE);
                  >
                  > Later you commit or rollback the transaction:
                  > topicSession.commit();
                  > topicSession.rollback();
                  >
                  > Reader of queue will not see the message until the
                  > commit just like a DB.

                  Thx. I found it in the JMS-doc. Just that you normally don't need to do it like you say above. You can just use the normal container managed transactions, and it will work on JMS too.

                  • 6. Re: JMS publish roll-back
                    philc

                    JMS using Container managed transactions without calling session.commit() or session.rollback()

                    > You can just use the normal container managed
                    > transactions, and it will work on JMS too.

                    I am trying to do this but i doesn't work. The messages seem to be blocked. (The listener never gets them). Could you show me and example.

                    Philippe