how and why do you use jms/mdb instead of the scheduler servlet?????
We have a similar design and faced the same issue. It is follows the one in the wiki http://wiki.jboss.org/wiki/Wiki.jsp?page=JBPMJMS.
jBPM is wrapped by a web service which allows to begin a workflow and send signals. All actions send a JMS message to worker MDBs which perform the work asynchronously and signal back through the web service.
We also have some async steps which send a JMS message in the Delegate Action and go to a wait state. However, jBPM continues to do other work in other tokens (branches) and does not save the process instance before an MDB receives the message, does the work, and tries to signal back. That signal (which is executed in a different thread by the web service) tries to look up the process instance/token and fails.
As a workaround, we also put in some delay and retry logic into the MDB. A better solution IMO would be to make JMS and Hibernate transactions part of a distributed transaction (using XA); that way, JMS messages will not be sent ahead of the database commits. Our infrastructure (Database and Application Server) doesn't allow us to do that just yet.
FWIW, same problem discussed in http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4008454#4008454
and in a few others, I think.
This is especially nasty because it's timing-dependent; if a developer's unlucky, the MDB will be slow enough to work MOST of the time, and it will be the devil to diagnose.
I think you're right - XA is the answer.