-
1. Re: RE: how to set parent process variable in call-activity (sub-process) (not at the end) but in the middle
sanjay05222 Jan 29, 2015 1:23 PM (in response to sai.ve.5)Hi Sai.
Lets say you have Process A with a "Sub Process Activity SP" whose called element is "Sub Process B". You have to take the Process A's Sub Process Activity and assign the input and output variables. Now looks like that to me this Input and Output variables are in the kcontext before the control is passed to the Sub Process Inside the Process B, retrieve them via getVariable Method in kcontext and it will work. I hope this helps.
Thanks
Sanjay Gautam,
(If you think answer was helpful please mark it so )
-
2. Re: RE: how to set parent process variable in call-activity (sub-process) (not at the end) but in the middle
sai.ve.5 Jan 30, 2015 12:39 AM (in response to sanjay05222)There's a correction to my question. I didn't phrase it properly:
I would like the data i got in sub-process (in a script task) to be assigned to a variable in parent process. It would work when sub-process ends but i need the data at that instant of time. I'm not able to do that. kcontext.setVariable - to access parent process variable return with "error - process variable does not exist" as it appears to look only at the sub-process level
Regards,
Sai -
3. Re: RE: how to set a value to a parent process variable in call-activity (sub-process) (not at the end) but in the middle
swiderski.maciej Feb 2, 2015 1:34 AM (in response to sai.ve.5)you can either use signal events with event data being the variable and then your parent process would need to listen to that event or you can load parent process from within you child process and manually set variable on it. My recommendation would be to use signals for that as it goes via standard api - note that by default signals are broadcasts so it will signal all process isntances listening to given signal. But you can direct it to given instance as well by using:
kcontext.getKieRuntime().signalEvent(name, data, pInstanceId)
and you can do that from child process script task.
HTH
-
4. Re: RE: how to set a value to a parent process variable in call-activity (sub-process) (not at the end) but in the middle
sanjay05222 Feb 2, 2015 2:32 AM (in response to sai.ve.5). . wrote:
There's a correction to my question. I didn't phrase it properly:
I would like the data i got in sub-process (in a script task) to be assigned to a variable in parent process. It would work when sub-process ends but i need the data at that instant of time. I'm not able to do that. kcontext.setVariable - to access parent process variable return with "error - process variable does not exist" as it appears to look only at the sub-process level
Regards,
SaiHi Sai ,
I am not sure what will be benefit to update the parent process variable even before the sub process finishes ? what is the scenario you want to accomplish. ?
-
5. Re: RE: how to set a value to a parent process variable in call-activity (sub-process) (not at the end) but in the middle
sai.ve.5 Feb 6, 2015 10:11 AM (in response to sanjay05222)we use our own database for our application and we talk to BPM for stateful processes (for now with wait states). Claim, start, complete (if human) is accomplished using our database and storing process instance id's. Since, we spawn child processes, we couldn't signal or complete human tasks using parent process id alone. Hence, this workaround.
Thanks
-
6. Re: RE: how to set parent process variable in call-activity (sub-process) (not at the end) but in the middle
songwen.xie Mar 26, 2019 1:44 PM (in response to swiderski.maciej)Hi Maciej,
I implemented my workflow using RedHat Business Central version 6.4GA. I also need to set a value in parent process instance from a sub process instance. I used kcontext.getKieRuntime().signalEvent(name, data, pInstanceId). The following is the content of the script task of reusable subprocess:
logger.debug("process instance id: " + kcontext.getProcessInstance().getId());
long parentId = kcontext.getProcessInstance().getParentProcessInstanceId();
logger.debug("parent process instance id: " + parentId);
kcontext.getKieRuntime().signalEvent("childProcessReport", workflowId, parentId);
Do you know why I am getting following exception? Thanks!
11:52:24,256 INFO [stdout] (Log4j2-TF-2-AsyncLoggerConfig-1) 11:52:24.255 DEBUG : process instance id: 28
11:52:24,256 INFO [stdout] (Log4j2-TF-2-AsyncLoggerConfig-1) 11:52:24.255 DEBUG : parent process instance id: 27
11:52:24,308 WARN [org.kie.remote.services.cdi.ProcessRequestBean] (default task-17) Unable to execute SignalEventCommand/0: org.kie.remote.services.rest.exception.KieRemoteRestOperationException: [OrderWorkFlow.front-delivery:28 - Report WorkflowId:151] -- Invalid session was used for this context org.kie.internal.runtime.manager.context.ProcessInstanceIdContext@c9e434
at org.kie.remote.services.rest.exception.KieRemoteRestOperationException.internalServerError(KieRemoteRestOperationException.java:151)
at org.kie.remote.services.cdi.ProcessRequestBean.doKieSessionOperation(ProcessRequestBean.java:305)
at org.kie.remote.services.cdi.ProcessRequestBean.processCommand(ProcessRequestBean.java:205)
at org.kie.remote.services.cdi.ProcessRequestBean$Proxy$_$$_WeldClientProxy.processCommand(Unknown Source)
at org.kie.remote.services.util.ExecuteCommandUtil.restProcessJaxbCommandsRequest(ExecuteCommandUtil.java:61)
at org.kie.remote.services.rest.ExecuteResourceImpl.execute(ExecuteResourceImpl.java:60)
at org.kie.remote.services.rest.ExecuteResourceImpl$Proxy$_$$_WeldClientProxy.execute(Unknown Source)
at sun.reflect.GeneratedMethodAccessor315.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:139)
at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:295)
at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:249)
at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:236)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:395)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:202)
at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:221)
at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56)
at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)
at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129)
at org.kie.remote.services.rest.jaxb.DynamicJaxbContextFilter.doFilter(DynamicJaxbContextFilter.java:67)
at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
at org.uberfire.ext.security.server.BasicAuthSecurityFilter.doFilter(BasicAuthSecurityFilter.java:70)
at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
at org.uberfire.ext.security.server.SecureHeadersFilter.doFilter(SecureHeadersFilter.java:69)
at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
at org.uberfire.ext.security.server.SecurityIntegrationFilter.doFilter(SecurityIntegrationFilter.java:57)
at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84)
at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)
at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.security.handlers.AuthenticationConstraintHandler.handleRequest(AuthenticationConstraintHandler.java:51)
at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
at io.undertow.servlet.handlers.security.ServletSecurityConstraintHandler.handleRequest(ServletSecurityConstraintHandler.java:56)
at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:285)
at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:264)
at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)
at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:175)
at io.undertow.server.Connectors.executeRootHandler(Connectors.java:202)
at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:792)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.jbpm.workflow.instance.WorkflowRuntimeException: [OrderWorkFlow.front-delivery:28 - Report WorkflowId:151] -- Invalid session was used for this context org.kie.internal.runtime.manager.context.ProcessInstanceIdContext@c9e434
at org.jbpm.workflow.instance.impl.NodeInstanceImpl.executeAction(NodeInstanceImpl.java:206)
at org.jbpm.workflow.instance.node.ActionNodeInstance.internalTrigger(ActionNodeInstance.java:48)
at org.jbpm.workflow.instance.impl.NodeInstanceImpl.trigger(NodeInstanceImpl.java:173)
at org.jbpm.workflow.instance.impl.NodeInstanceImpl.triggerNodeInstance(NodeInstanceImpl.java:366)
at org.jbpm.workflow.instance.impl.NodeInstanceImpl.triggerCompleted(NodeInstanceImpl.java:325)
at org.jbpm.workflow.instance.impl.ExtendedNodeInstanceImpl.triggerCompleted(ExtendedNodeInstanceImpl.java:44)
at org.jbpm.workflow.instance.node.EventNodeInstance.triggerCompleted(EventNodeInstance.java:82)
at org.jbpm.workflow.instance.node.EventNodeInstance.signalEvent(EventNodeInstance.java:63)
at org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl.signalEvent(WorkflowProcessInstanceImpl.java:526)
at org.drools.core.command.runtime.process.SignalEventCommand.execute(SignalEventCommand.java:125)
at org.drools.core.command.runtime.process.SignalEventCommand.execute(SignalEventCommand.java:39)
at org.drools.core.command.impl.DefaultCommandService.execute(DefaultCommandService.java:36)
at org.drools.core.command.impl.AbstractInterceptor.executeNext(AbstractInterceptor.java:41)
at org.drools.persistence.SingleSessionCommandService$TransactionInterceptor.execute(SingleSessionCommandService.java:604)
at org.drools.core.command.impl.AbstractInterceptor.executeNext(AbstractInterceptor.java:41)
at org.drools.persistence.jpa.OptimisticLockRetryInterceptor.execute(OptimisticLockRetryInterceptor.java:82)
at org.drools.core.command.impl.AbstractInterceptor.executeNext(AbstractInterceptor.java:41)
at org.drools.persistence.jta.TransactionLockInterceptor.execute(TransactionLockInterceptor.java:73)
at org.drools.persistence.SingleSessionCommandService.execute(SingleSessionCommandService.java:397)
at org.drools.core.command.impl.CommandBasedStatefulKnowledgeSession.execute(CommandBasedStatefulKnowledgeSession.java:520)
at org.jbpm.kie.services.impl.ProcessServiceImpl.execute(ProcessServiceImpl.java:488)
at org.jbpm.services.cdi.impl.ProcessServiceCDIImpl$Proxy$_$$_WeldClientProxy.execute(Unknown Source)
at org.kie.remote.services.cdi.ProcessRequestBean.doKieSessionOperation(ProcessRequestBean.java:298)
... 61 more
Caused by: java.lang.IllegalStateException: Invalid session was used for this context org.kie.internal.runtime.manager.context.ProcessInstanceIdContext@c9e434
at org.jbpm.runtime.manager.impl.PerProcessInstanceRuntimeManager.validate(PerProcessInstanceRuntimeManager.java:214)
at org.jbpm.persistence.processinstance.JPAProcessInstanceManager.getProcessInstance(JPAProcessInstanceManager.java:107)
at org.jbpm.process.instance.ProcessRuntimeImpl.getProcessInstance(ProcessRuntimeImpl.java:283)
at org.jbpm.process.instance.ProcessRuntimeImpl.getProcessInstance(ProcessRuntimeImpl.java:279)
at org.drools.core.impl.StatefulKnowledgeSessionImpl.getProcessInstance(StatefulKnowledgeSessionImpl.java:1918)
at org.jbpm.process.instance.event.DefaultSignalManager.signalEvent(DefaultSignalManager.java:88)
at org.jbpm.process.instance.ProcessRuntimeImpl.signalEvent(ProcessRuntimeImpl.java:486)
at org.drools.core.impl.StatefulKnowledgeSessionImpl.signalEvent(StatefulKnowledgeSessionImpl.java:561)
at org.jbpm.Process_org$u46$jbpm$u46$Front$u45$Delivery$u45$Subprocess2109514247.action93(Process_org$u46$jbpm$u46$Front$u45$Delivery$u45$Subprocess2109514247.java:1088)
at org.jbpm.Process_org$u46$jbpm$u46$Front$u45$Delivery$u45$Subprocess2109514247Action93Invoker.execute(Process_org$u46$jbpm$u46$Front$u45$Delivery$u45$Subprocess2109514247Action93Invoker.java:15)
at org.jbpm.workflow.instance.impl.NodeInstanceImpl.executeAction(NodeInstanceImpl.java:200)