JBoss Community

Signal a wait state and suspend related running subprocesses

created by Stefano Cancedda in jBPM - View the full discussion

Hi All,
I'm trying to realize a complex use case with Jbpm 4, and I'm lookin for some advises and answers.
My requisites are to implements some kind of "phases" inside a business process (which models an authorization issuing system
for a governative trade organization) that can be "modular" and pluggable to the basis of some normative & legal factors.
I've move to the use of sub-processes in order to implement this, using a dynamic el expression to decide in runtime what process definition of
instantiate as sub-process, via parameterizing the jpdl sub-process' key attribute.
So the structure is composed by a main process, that groups these phases, and many other subprocesses which can can be
authored by external system and business designers.
Another requisite is that in one phase (es: when an integration request is started) the main process is paused,
a timer is started (the pause cannot be longer than a business value, and users must be notified if the suspension is reaching it's limit),
and then resumed.
For authoring sub-process I don't find seamless to design for any subprocess some kind of a "suspension" state
(this would be always present, and redundant), so I'm thinking to enforce the suspension state at the level of the main process:

Hi All,

 

I'm trying to realize a complex use case with Jbpm 4, and I'm lookin for some advises and answers.

My requisites are to implements some kind of "phases" inside a business process (which models an authorization issuing system for a governative trade organization) that must be "modular" and pluggable to the basis of some normative & legal factors.

 

I've move to the use of sub-processes in order to implement this, using a dynamic el expression to decide in runtime what process definition of  instantiate as sub-process, via parameterizing the jpdl sub-process' key attribute.

 

So the structure is composed by a main process, that groups these phases, and many other subprocesses which can can be

authored by external system and business designers.

 

Another requisite is that in one phase (es: when an integration request is started) the main process is paused,

a timer is started (the pause cannot be longer than a business value, and users must be notified if the suspension is reaching it's limit),

and then resumed.

For authoring sub-process I don't find seamless to design for any subprocess some kind of a "suspension" state

(this would be always present, and redundant), so I'm thinking to enforce the suspension state at the level of the main process:

 

http://community.jboss.org/servlet/JiveServlet/downloadImage/2-563527-9328/450-254/process.jpg

I cannot use the execution suspension of the main process, because of the timer's requisite (execution "suspended" state, also suspend timers and notifications),and I cannot end the sub-process because formally, at the end of the "wait" period it must progress where the sub-process was left.
The problem is that when signaling the main execution to the "Suspend" state, there is a running sub-process instance that invalidate the operation:

 

      1. EXCEPTION ###########################################10:42:32,067 INF | Signal a wait state and suspend related running subprocesses exception while executing command org.jbpm.pvm.internal.cmd.SignalCmd@3ce40org.jbpm.api.JbpmException: execution[MainProcess.50026] has running subprocess: execution[SubProcessRequisitesEvaluation.340002] in state inactive-scope     at org.jbpm.pvm.internal.model.ExecutionImpl.checkActive(ExecutionImpl.java:1090)     at org.jbpm.pvm.internal.model.ExecutionImpl.signal(ExecutionImpl.java:427)     at org.jbpm.pvm.internal.cmd.SignalCmd.execute(SignalCmd.java:61)     at org.jbpm.pvm.internal.cmd.SignalCmd.execute(SignalCmd.java:35)     at org.jbpm.pvm.internal.svc.DefaultCommandService.execute(DefaultCommandService.java:42)     at org.jbpm.pvm.internal.tx.SpringCommandCallback.doInTransaction(SpringCommandCallback.java:45)     at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:130)     at org.jbpm.pvm.internal.tx.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:49)     at org.jbpm.pvm.internal.svc.EnvironmentInterceptor.executeInNewEnvironment(EnvironmentInterceptor.java:53)     at org.jbpm.pvm.internal.svc.EnvironmentInterceptor.execute(EnvironmentInterceptor.java:40)     at org.jbpm.pvm.internal.svc.RetryInterceptor.execute(RetryInterceptor.java:56)     at org.jbpm.pvm.internal.svc.ExecutionServiceImpl.signalExecutionById(ExecutionServiceImpl.java:93)

 

I've tried to suspend the sub-process activity execution and resume the main-process activity that maps the sub-process execution (the one in "inactive-scope" state) but it have no effect:

... ExecutionImpl execution = (ExecutionImpl) executionService.findExecutionById(processId);logger.info( "MAIN-PROCESS STATE= " + processId + " " + execution.getState() );if(execution.getSubProcessInstance() != null){     logger.info( "SUB_PROCESS STATE= " + execution.getSubProcessInstance().getId() + " " +                               execution.getSubProcessInstance().getState() );               if(Execution.STATE_INACTIVE_SCOPE.equalsIgnoreCase(execution.getSubProcessInstance().getState())){                    ExecutionImpl state = execution.getSubProcessInstance().findActiveExecutionIn(activeState);          state.suspend();          execution.getSubProcessInstance().suspend();          logger.info( "SUB_PROCESS STATE= " + execution.getSubProcessInstance().getId() + " " +                               execution.getSubProcessInstance().getState() );          logger.info( "SUB_PROCESS ACTIVITY STATE " + state + " " + state.getState() );          execution.resume();          logger.info( "MAIN-PROCESS STATE " + execution + " " + execution.getState() );     }}                                   executionService.signalExecutionById(processId, transitionName, variables);

this is the log:

INFO  ProcessServiceBean - Active state: EVALUATIONINFO  ProcessServiceBean - MAIN-PROCESS STATE= MainProcess.50026 active-rootINFO  ProcessServiceBean - SUB_PROCESS STATE= SubProcessRequisitesEvaluation.340002 inactive-scopeINFO  ProcessServiceBean - SUB_PROCESS STATE= SubProcessRequisitesEvaluation.340002 suspendedINFO  ProcessServiceBean - SUB_PROCESS ACTIVITY STATE= execution[SubProcessRequisitesEvaluation.340002.TaxCompliance.340005] suspendedINFO  ProcessServiceBean - MAIN-PROCESS STATE execution[MainProcess.50026] active-root### EXCEPTION ###########################################12:05:39,201 INF | Signal a wait state and suspend related running subprocesses exception while executing command org.jbpm.pvm.internal.cmd.SignalCmd@ebd0beorg.jbpm.api.JbpmException: execution[MainProcess.50026] has running subprocess: execution[SubProcessRequisitesEvaluation.340002] in state suspended     at org.jbpm.pvm.internal.model.ExecutionImpl.checkActive(ExecutionImpl.java:1090)     at org.jbpm.pvm.internal.model.ExecutionImpl.signal(ExecutionImpl.java:427)     at org.jbpm.pvm.internal.cmd.SignalCmd.execute(SignalCmd.java:61)     at org.jbpm.pvm.internal.cmd.SignalCmd.execute(SignalCmd.java:35

So, I'm wondering if the behaviour of Jbpm is wrong or if it's supposed to work in this way (namely: "cannot signal parent execution id subprocess are suspended"),  or BTW if there is a common way to implement this set of requisites.
thank you in advance for any help you can give me!

Reply to this message by going to Community

Start a new discussion in jBPM at Community