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);
ts = topicConnection.createTopicSession(true, 0);
tp = ts.createPublisher(topic);
TextMessage tm = ts.createTextMessage();
tm.setStringProperty("Action", nAction.toString() );
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.
Have you read the free JMS doc on jboss.org?