[jboss-user] [jBPM] - Re: A question on the external event using event Correlation

byungwoojun do-not-reply at jboss.com
Tue Mar 15 16:09:05 EDT 2011

byungwoojun [http://community.jboss.org/people/byungwoojun] created the discussion

"Re: A question on the external event using event Correlation"

To view the discussion, visit: http://community.jboss.org/message/593362#593362

Thanks, Mauricio and Jim! After receiving replies from both of you, I did give some thoughts on this, and read some of blogs that Kris V. was involved. Here is my plan:

In my business layer, when a JMS message arrives (it can be Web service, EJB, POJO, etc. - does not matter), it parses the message/object for a unique correlation id (the correlation id can consist of many field values to make it unique if necessary) and other key fields. It uses the emf to persist (cache) the knowledge session, and saves the knowledge session id and process instance id (after startprocess) along with the correlation id into a mapping database table. So, in the mapping table has the correlation id - session id - process instance id and other key fields per table row. 

Later, an external client (partner) sends a JMS message that has the correlation id that matches the above correlation id. Using the correlation id from the message, it will retrieve the session id and process instance id from the mapping table. Then, using the JPAKnowledgeService.loadStatefulKnowledgeSession (session_id, kbase, null, env), it will restore the session. Since the session can have multiple process instances, it will locate the right process instance from the session using the ksession.getProcessInstance (process id).

Once it gets the process instance, using the event type (the event type can also come from the external message, or some other mapping is possible), it can inject the intermedidate message event to the right place, using the signal event, e.g., processInstance.signalEvent("event Type", data); Once the process is complete, we can purge the corresponding data from the mapping table. 

If I don't use the emf, I think I can use the kbase.getStatefulKnowledgeSessions() to get a collection of sessions - there is an assumption that the kbase is static. Then, in a loop, I can find the right session by comparing the session.getId() with the session id from the mapping table. Since the kbase is static which is per JVM, it may cause some issues to run the jBPM 5 in a clustered environment. So, I prefer to restore the session from the database (persistence).

That's the basic idea. Any comments will be appreciated. 

I used to use that BPEL, the correlation support is part of the process configuration (usign some BPEL IDE), not part of business layer. In jBPM 5, it seems to me that I need to handle the correlation support as above.


Reply to this message by going to Community

Start a new discussion in jBPM at Community

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20110315/10b8b68d/attachment-0001.html 

More information about the jboss-user mailing list