4 Replies Latest reply on Oct 23, 2006 5:12 AM by magnus ehdwall

    Problem with transaction rollback

    magnus ehdwall Newbie

      I have an EJB business method that does two tasks;
      1) Calls another EJB:s business method which sends a message to a topic.
      2) Updates a database table.

      See code below.

      I would like theese tasks done within a single transaction, so I have annotated the business methods involved accordingly. The problem is that even if I mark the transaction with setRollbackOnly() before it returns, the message is still put on the topic and read by its' consumer, while the database is not updated..

      As can be seen by my pseudo-code below, I have not set the session to be transacted (if I do the messages are never consumed), but those settings should be ignored in EJB:s accordingly to the ejb-spec anyway.

      What am I doing wrong?

      public @Stateless BusinessServiceBean implements BusinessService {

      public void doStuff() {

      public @Stateless SenderServiceBean implements SenderService {

      public void sendMessage(..) {
      Session s = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
      producer = session.createProducer(topic);