Jim B [
https://community.jboss.org/people/jamesbeam] created the discussion
"Design pattern for routing to multiple jBPM processes?"
To view the discussion, visit:
https://community.jboss.org/message/804680#804680
--------------------------------------------------------------
I am using jBPM 5.4 with persistence. I am still a jBPM noob, so thanks in advance for
your patience getting through this explanation...
I have a ksession that will be running multiple long-running processes. These process
flows are the same - only the variables in the processes are different.
The basic use case it that I have events coming into a "router" that based upon
message content will be passed to an existing process instance (if the related process
exists). If a process instance does not yet exist for that event, a new one is created.
I would greatly appreciate any thoughts on design patterns to implement this (managing
processes in the kession and routing events to them).
Relating to design, I have considered;
1) Create a single-node process with a "routing" WorkItemHandler node. This
instance will receive the event and perform all of the checking/routing/process
instantiation logic. Basically, iterate through each process in the kession for the
2) Create business rules that checks for (and creates) objects in the ksession
representing each process that is running.
Pseudo code for rules would be something like:
rule "Send to existing process"
when
$newEventBean : NewEventBean()
$myProcessBean : MyProcessBean(subject matches $newEventBean.subject)
then
<signal $myProcessBean.processId with $newEventBean>
rule "Create if process doesn't exist"
when
$newEventBean : NewEventBean()
not($myProcessBean : MyProcessBean(subject matches $newEventBean.subject))
then
$newProcessBean: NewProcessBean();
$newProcessBean.subject = $newEventBean.subject;
$newProcessBean.instantiate(thisKsession); <<---inserts new
process instance into ksession
insert($newProcessBean);
(and when a process ends, it would need to retract the related newProcessBean)
I am more familiar with java development than drools rule-jbpm integration, so I am
leaning towards option 1. (Specifically, for example, I'm not sure how to create a
process from a rule or how to signal one, so I'd more likely to implement methods like
NewProcessBean.instantiate() in a java method in my newProcessBean anyway :) )
Any thoughts about option 1 or 2? Am I missing a more obvious/better solution?
(Possibly something like sending a signal to a ksession where the correct process catches
it and acknowledges it in some way - so that if an acknowledgement isn't received a
new process is created. Can a process be configured to ALWAYS catch a signal AFTER
another process, so that my "final" process could act like an
"otherwise" statement and would just instantiate a new process?)
Thank you again for any thoughts,
-J
--------------------------------------------------------------
Reply to this message by going to Community
[
https://community.jboss.org/message/804680#804680]
Start a new discussion in jBPM at Community
[
https://community.jboss.org/choose-container!input.jspa?contentType=1&...]