Discussion:
[jboss-user] [jBPM] - Re: Design pattern for routing to multiple jBPM processes?
Maciej Swiderski
2013-03-29 17:09:40 UTC
Permalink
Maciej Swiderski [https://community.jboss.org/people/swiderski.maciej] created the discussion

"Re: Design pattern for routing to multiple jBPM processes?"

To view the discussion, visit: https://community.jboss.org/message/805552#805552

--------------------------------------------------------------
Looks like a perfect case for correlated process instances - meaning that you can assign business key to process instances that later on can be used to get hold of process instance. That will come in with version 6.0. And in meantime...

option 1 has an issue if you consider to use persistence (and I assume you do as there are long running processes). The issue is you cannot simply query for processes in that session as process instance resides in ksession only when it is being currently executed/processed by the engine. As soon as it reaches a safe state it is persisted and removed from ksession to save memory, etc

Option 2 is one way to go and you can easily create processes from rules and as you said you need to make sure you retract fact when process completes.

HTH
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/805552#805552]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Jim B
2013-04-01 21:40:48 UTC
Permalink
Jim B [https://community.jboss.org/people/jamesbeam] created the discussion

"Re: Design pattern for routing to multiple jBPM processes?"

To view the discussion, visit: https://community.jboss.org/message/805869#805869

--------------------------------------------------------------
Maciej, thank you for your response - being able to assign a business key sounds ideal. 

Unfortunately, I have just about completed option one (of course!)  I am using the processinstancelog to find active processes:

     List<ProcessInstanceLog> pil = JPAProcessInstanceDbLog.findActiveProcessInstances(myProcessName)

My test program uses a signal to insert the object to a "routing" process (a start/stop node with my RoutingWorkItemHandler in the middle).  This process uses a signal start node, so it instantiates at each signal.

To your point, it seems pretty kludgy to use transactions yet rely on the log to get the process ids.  However, thus far things seem to be working - I have inserted several signals at once and they have been properly handled.  Specifically, when I insert two of the same signals back to back, the RoutingWorkItemHandler sees the process from the previous signal and thus does not create a new one.  I made the executeWorkItem method in my RoutingWorkItemHandler synchronized, but it doesn't seem necessary.

So, my question is, does this seem logical to you, or does it just seem like dumb luck?

Thanks again,
-J
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/805869#805869]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Demian Calcaprina
2013-04-02 01:59:37 UTC
Permalink
Demian Calcaprina [https://community.jboss.org/people/calca] created the discussion

"Re: Design pattern for routing to multiple jBPM processes?"

To view the discussion, visit: https://community.jboss.org/message/805885#805885

--------------------------------------------------------------
Hey. In my opinion, it could work ok to use the audit tables (or some other table if you implement your own process instance listener if you have some problem with transactions).

But having a single node process to make the routing seems a bit unnatural in contrast to using rules to make it. I think using rules for this will give you more flexibility to add more cases into the future, and easier to understand.

My 2 cents :)

Demian
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/805885#805885]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Loading...