1 Reply Latest reply on Mar 5, 2002 7:48 AM by Peter Antman

    Can the container commit a Topic Session?

    Tone Hansen Newbie

      When an entity bean is created, updated and removed, I send JMS to a specific topic.
      I use the following code to send the JMS:
      Topic topic = (Topic) context.lookup(topicName);
      TopicSession ts;
      TopicPublisher tp;
      ts = topicConnection.createTopicSession(true, 0);
      tp = ts.createPublisher(topic);
      TextMessage tm = ts.createTextMessage();
      tm.setText(nPkId.toString());
      tm.setIntProperty("MessageType",nMsgType );
      tm.setStringProperty("Action", nAction.toString() );
      tp.publish(message);
      ts.commit();

      As you can see my last command is the commit(). This means that the JMS is committed at once.

      What I would like to do is to let JBoss commit this when the session and entity beans are committed, so that no commit are performed if the container gets a transaction rollback.

      Any ideas on how to achieve this?

      PS: There may be more than one JMS that are sent, and the bean that initiates the JMS is not the 'last bean' to be run in the transaction. The 'outer-most' bean does not know which JMS that have been sent.

      Tone