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 {
@TransactionAttribute(REQUIRES_NEW)
public void doStuff() {
...
senderService.sendMessage(..);
saveStuffToDb(..);
sessionContext.setRollbackOnly();
}
}
public @Stateless SenderServiceBean implements SenderService {
@TransactionAttribute(REQUIRED)
public void sendMessage(..) {
...
Session s = connection.createSession(false,
Session.AUTO_ACKNOWLEDGE);
producer = session.createProducer(topic);
producer.sendMessage(..)
}
}
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3979672#3979672
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3979672
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user