[jBPM] - Running Business Rule in a Multi Threaded Environment (JEE)
by Mehul Vyas
Mehul Vyas [https://community.jboss.org/people/vyasmehul] created the discussion
"Running Business Rule in a Multi Threaded Environment (JEE)"
To view the discussion, visit: https://community.jboss.org/message/806005#806005
--------------------------------------------------------------
Hello,
We are using JBoss BRMS 5.3 on Websphere Application Server 8.x. We are using batch processing framework and hence on J2EE environment there would be multiple instances of a job processing data. Now the issue is that the processing framework we use supports parallel job execution. The same is probably not supported in JBoss BRMS due to which while executing business rule in a parallel mode the following exception is seen. The code to execute business rule is as below:
knowledgeBase = knowledgeAgent.getKnowledgeBase();
statefulKnowledgeSession = knowledgeBase
.newStatefulKnowledgeSession();
statefulKnowledgeSession.getAgenda().getAgendaGroup(agendaName)
.setFocus();
if (!commands.isEmpty()) {
// execute the business rule
commands.add(CommandFactory.newFireAllRules());
executionResults = statefulKnowledgeSession
.execute(CommandFactory.newBatchExecution(commands));
}
at in.gov.tds.util.JbrmsUtil.executeBusinessRule(JbrmsUtil.java:230)
at in.gov.tds.processing.bo.impl.DefaultProcessingBOImpl.getInterestRate(DefaultProcessingBOImpl.java:192)
at in.gov.tds.processing.batchprocessor.DefaultAndInterestComputationBatchProcessor.getInterestRateMap(DefaultAndInterestComputationBatchProcessor.java:931)
at in.gov.tds.processing.batchprocessor.DefaultAndInterestComputationBatchProcessor.processRecord(DefaultAndInterestComputationBatchProcessor.java:292)
at com.ibm.websphere.batch.devframework.steps.technologyadapters.GenericXDBatchStep.processRecord(GenericXDBatchStep.java:263)
at com.ibm.websphere.batch.devframework.steps.technologyadapters.GenericXDBatchStep.processJobStep(GenericXDBatchStep.java:227)
at com.ibm.ws.gridcontainer.batch.impl.StepManagerImpl._regularJobBatchLoop(StepManagerImpl.java:1200)
at com.ibm.ws.gridcontainer.batch.impl.StepManagerImpl.executeStep(StepManagerImpl.java:368)
at com.ibm.ws.gridcontainer.security.actions.ExecuteStepBatchUserPrivilegedAction.executeAction(ExecuteStepBatchUserPrivilegedAction.java:47)
at com.ibm.ws.gridcontainer.security.AbstractUserPrivilegedAction.runWithoutSecurity(AbstractUserPrivilegedAction.java:66)
at com.ibm.ws.gridcontainer.services.impl.WASRunUnderCredentialServiceImpl.runUnderUserCredential(WASRunUnderCredentialServiceImpl.java:134)
at com.ibm.ws.gridcontainer.services.impl.WASRunUnderCredentialServiceImpl.runActionUnderUserCredential(WASRunUnderCredentialServiceImpl.java:386)
at com.ibm.ws.gridcontainer.batch.impl.JobManagerImpl._sequentialStepScheduling(JobManagerImpl.java:746)
at com.ibm.ws.gridcontainer.batch.impl.JobManagerImpl.executeJob(JobManagerImpl.java:198)
at com.ibm.ws.batch.BatchJobControllerWork._runJob(BatchJobControllerWork.java:299)
at com.ibm.ws.batch.BatchJobControllerWork.run(BatchJobControllerWork.java:219)
at com.ibm.ws.asynchbeans.J2EEContext$RunProxy.run(J2EEContext.java:269)
at java.security.AccessController.doPrivileged(AccessController.java:229)
at com.ibm.ws.asynchbeans.J2EEContext.run(J2EEContext.java:795)
at com.ibm.ws.asynchbeans.WorkWithExecutionContextImpl.go(WorkWithExecutionContextImpl.java:222)
at com.ibm.ws.asynchbeans.ABWorkItemImpl.run(ABWorkItemImpl.java:206)
at java.lang.Thread.run(Thread.java:770)
Caused by: java.util.NoSuchElementException
at java.util.LinkedList.getLast(LinkedList.java:548)
at org.drools.common.DefaultAgenda.getNextFocus(DefaultAgenda.java:607)
at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:1020)
at org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1251)
at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:737)
at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:701)
at org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:218)
at org.drools.command.runtime.rule.FireAllRulesCommand.execute(FireAllRulesCommand.java:106)
at org.drools.command.runtime.rule.FireAllRulesCommand.execute(FireAllRulesCommand.java:32)
at org.drools.command.runtime.BatchExecutionCommandImpl.execute(BatchExecutionCommandImpl.java:155)
at org.drools.command.runtime.BatchExecutionCommandImpl.execute(BatchExecutionCommandImpl.java:76)
at org.drools.impl.StatefulKnowledgeSessionImpl.execute(StatefulKnowledgeSessionImpl.java:809)
at org.drools.impl.StatefulKnowledgeSessionImpl.execute(StatefulKnowledgeSessionImpl.java:781)
at in.gov.tds.util.JbrmsUtil.executeBusinessRule(JbrmsUtil.java:220)
... 21 more
1) Is this known? Can we change the code to make it synchronized and hence to make it thread safe?
2) Is this known issue? Are there any workaround to resolve this issue other than changing code to make it synchronized because J2EE environment is thread safe?
Thanks,
Mehul
--------------------------------------------------------------
Reply to this message by going to Community
[https://community.jboss.org/message/806005#806005]
Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&con...]
11 years, 1 month
[jBPM] - Cannot make Evaluation example work consistently in Eclipse
by Andy McC
Andy McC [https://community.jboss.org/people/andymcc] created the discussion
"Cannot make Evaluation example work consistently in Eclipse"
To view the discussion, visit: https://community.jboss.org/message/805968#805968
--------------------------------------------------------------
Hi,
Although I'm a newbie, please be assured that I've tried to resolve this one before posting, but it looks like others have hit similar issues in the past ( https://community.jboss.org/message/750417#750417 https://community.jboss.org/message/750417#75041).
I'm seeing the same issue on two different machines, one running Windows 7 the other Windows 8, both running Java SE runtime 1.7.0_17-b02.
I'm running the example "straight out of the box" without any modifications. Here's what I'm seeing:
* I've installed jBPM_5.4.0_final and Eclipse Helios as per the installation documentation.
* In Eclipse, I run the Evaluation example in Debug with a breakpoint at the +logger.close()+ instruction, and complete all the krisv, john and mary tasks.
* In Eclipse, I then press the green arrow in the Debug session to complete the execution.
* All good so far.
* However, if I immediately try to rerun the Evaluation example, there is a pause and I see the following in the console window (apologies for the formatting!):
| 1 | 02/04 11:23:07,519[main] ERROR workitem.wsht.GenericHTWorkItemHandler.executeWorkItem - Tue Apr 02 11:23:07 BST 2013: Error when creating task on task server for work item id 1. Error reported by task server: Task operation request timed out |
java.lang.RuntimeException: Task operation request timed out
| | at org.jbpm.task.service.SyncTaskServiceWrapper.addTask(SyncTaskServiceWrapper.java:118) |
| | at org.jbpm.process.workitem.wsht.GenericHTWorkItemHandler.executeWorkItem(GenericHTWorkItemHandler.java:182) |
| | at org.drools.process.instance.impl.DefaultWorkItemManager.internalExecuteWorkItem(DefaultWorkItemManager.java:70) |
| | at org.jbpm.workflow.instance.node.WorkItemNodeInstance.internalTrigger(WorkItemNodeInstance.java:107) |
| | at org.jbpm.workflow.instance.impl.NodeInstanceImpl.trigger(NodeInstanceImpl.java:126) |
| | at org.jbpm.workflow.instance.impl.NodeInstanceImpl.triggerNodeInstance(NodeInstanceImpl.java:279) |
| | at org.jbpm.workflow.instance.impl.NodeInstanceImpl.triggerCompleted(NodeInstanceImpl.java:238) |
| | at org.jbpm.workflow.instance.node.StartNodeInstance.triggerCompleted(StartNodeInstance.java:49) |
| | at org.jbpm.workflow.instance.node.StartNodeInstance.internalTrigger(StartNodeInstance.java:41) |
| | at org.jbpm.workflow.instance.impl.NodeInstanceImpl.trigger(NodeInstanceImpl.java:126) |
| | at org.jbpm.ruleflow.instance.RuleFlowProcessInstance.internalStart(RuleFlowProcessInstance.java:35) |
| | at org.jbpm.process.instance.impl.ProcessInstanceImpl.start(ProcessInstanceImpl.java:194) |
| | at org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl.start(WorkflowProcessInstanceImpl.java:309) |
| | at org.jbpm.process.instance.ProcessRuntimeImpl.startProcessInstance(ProcessRuntimeImpl.java:170) |
| | at org.jbpm.process.instance.ProcessRuntimeImpl.startProcess(ProcessRuntimeImpl.java:140) |
| | at org.drools.common.AbstractWorkingMemory.startProcess(AbstractWorkingMemory.java:1098) |
| | at org.drools.impl.StatefulKnowledgeSessionImpl.startProcess(StatefulKnowledgeSessionImpl.java:320) |
| | at com.sample.ProcessTest.main(ProcessTest.java:32) |
|
| Process started ... |
The only way I've found to resolve this is to restart Jboss which I'm sure isn't the intended way.
Here's what I've tried/noticed
* I've tried inserting a ksession.dispose() after the logger.close() but this does not appear to clear the issue.
* I've "clean"ed the Eclipse project and restarted the debug session.
* I've noticed that the memory occupancy
* When the ProcessTest has apparently completed, the Eclipse session still appears to have several threads that keep running (see below)
| com.sample.ProcessTest at localhost:51000 | |
| | Daemon Thread [Old I/O client worker (channelId: 2149714, /127.0.0.1:51002 => /127.0.0.1:5153)] (Running) | |
| | Daemon Thread [Thread-0 (HornetQ-client-global-scheduled-threads-22781537)] (Running) | |
| | Daemon Thread [Thread-1 (HornetQ-client-global-scheduled-threads-22781537)] (Running) | |
| | Thread [Thread-2] (Running) | |
| | Daemon Thread [Thread-2 (HornetQ-client-global-scheduled-threads-22781537)] (Running) | |
| | Daemon Thread [Thread-3 (HornetQ-client-global-scheduled-threads-22781537)] (Running) | |
| | Daemon Thread [Thread-4 (HornetQ-client-global-scheduled-threads-22781537)] (Running) | |
| | Thread [DestroyJavaVM] (Running) | |
Can anyone shed any light on what might be going wrong here? I'm keen to get moving with jBPM but I'd really like to be confident that I can get the examples working realiably before using Eclipse as my test environment.
Many thanks!
Andy McC
--------------------------------------------------------------
Reply to this message by going to Community
[https://community.jboss.org/message/805968#805968]
Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&con...]
11 years, 1 month