[jboss-user] [jBPM] - Running Business Rule in a Multi Threaded Environment (JEE)

Mehul Vyas do-not-reply at jboss.com
Tue Apr 2 09:01:22 EDT 2013


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&containerType=14&container=2034]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20130402/9e60e0c7/attachment-0001.html 


More information about the jboss-user mailing list