Bug 780362 - (SOA-2771) Ruleflow broken inside BusinessRulesProcessor
Ruleflow broken inside BusinessRulesProcessor
Product: JBoss Enterprise SOA Platform 5
Classification: JBoss
Component: JBossESB (Show other bugs)
Unspecified Unspecified
urgent Severity urgent
: ---
: 5.1.0 GA,5.1.0.CR1
Assigned To: Kevin Conner
: Regression
Depends On: BRMS-542 SOA-2841
  Show dependency treegraph
Reported: 2011-01-14 04:27 EST by Lukáš Petrovický
Modified: 2011-02-17 03:47 EST (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Fedora 14, OpenJDK.
Last Closed: 2011-02-17 03:47:35 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
Quickstart_business_rules_service5_jbqa-1855.esb (12.33 KB, application/octet-stream)
2011-01-14 04:30 EST, Lukáš Petrovický
no flags Details
LATEST.drl (1.10 KB, application/octet-stream)
2011-01-14 04:30 EST, Lukáš Petrovický
no flags Details
defaultPackage.pkg (34.25 KB, application/vnd.apple.installer+xml)
2011-01-14 04:30 EST, Lukáš Petrovický
no flags Details
ruleflowIntg.rf (2.94 KB, application/x-shockwave-flash2-preview)
2011-01-14 04:30 EST, Lukáš Petrovický
no flags Details
subruleflowIntg.rf (776 bytes, application/x-shockwave-flash2-preview)
2011-01-14 04:30 EST, Lukáš Petrovický
no flags Details
business_rules_service5_jbqa-1855.log (8.85 KB, text/plain)
2011-01-14 04:30 EST, Lukáš Petrovický
no flags Details
business_rules_service5_qe.tar.bz2 (33.06 KB, application/x-bzip2)
2011-01-17 06:40 EST, Lukáš Petrovický
no flags Details
repository_export.zip (18.70 KB, application/zip)
2011-01-18 05:53 EST, Lukáš Petrovický
no flags Details
drools-core-5.1.0.BRMS.jar (2.01 MB, application/x-java-archive)
2011-01-20 11:26 EST, Tihomir Surdilovic
no flags Details
drools-core-5.1.0.BRMS.jar (2.01 MB, application/x-java-archive)
2011-01-24 11:16 EST, Tihomir Surdilovic
no flags Details

External Trackers
Tracker ID Priority Status Summary Last Updated
JBoss Issue Tracker SOA-2771 None None None Never

  None (edit)
Description Lukáš Petrovický 2011-01-14 04:27:00 EST
project_key: SOA

The following ruleflow (see attachment) doesn't execute properly inside BusinessRulesProcessor action. There are no exceptions in the log, just the following:

2011-01-14 10:13:15,400 DEBUG [org.jboss.soa.esb.lifecycle.LifecycleResource] (pool-46-thread-1) Creating resource using factory: org.jboss.internal.soa.esb.services.rules.DroolsRuleService$LifecycleRuleBaseStateFactory@41be1cac with identity ID-14
2011-01-14 10:13:15,413 DEBUG [org.jboss.internal.soa.esb.services.rules.DroolsRuleBaseState] (pool-46-thread-1) created new stateless session [1639720667]
2011-01-14 10:13:15,413 DEBUG [org.jboss.internal.soa.esb.services.rules.DroolsRuleBaseState] (pool-46-thread-1) created new runtime logger [1524320920]
2011-01-14 10:13:15,413 DEBUG [org.jboss.internal.soa.esb.services.rules.DroolsRuleBaseState] (pool-46-thread-1) calling execute(Iterable) on stateless session [1639720667]
2011-01-14 10:13:15,434 INFO  [STDOUT] (pool-46-thread-1) startRuleFlow
2011-01-14 10:13:15,435 INFO  [STDOUT] (pool-46-thread-1) rfg1a
2011-01-14 10:13:15,437 INFO  [STDOUT] (pool-46-thread-1) rfg1b
2011-01-14 10:13:15,437 DEBUG [org.jboss.internal.soa.esb.services.rules.DroolsRuleBaseState] (pool-46-thread-1) calling close() on runtime logger [1524320920]
2011-01-14 10:13:15,509 DEBUG [org.jboss.soa.esb.listeners.message.ActionProcessingPipeline] (pool-46-thread-1) executing processor 1 org.jboss.soa.esb.samples.quickstart.businessrules5jbqa1855.ReviewMessage@9e69443

See that after the activation of rfg1b, the ruleflow simply exits while it should do a lot more stuff, mainly activate rfg2a and rfg4. When launched from Guvnor deployed into the very same SOA instance, it works fine.

Attached is:
1) A RuleFlow and a subflow that is supposed to be called.
2) The DRL file containing all the ruleflow groups and their rules.
3) Audit log from the Drools execution, showing that it simply ends after rfg1b.
4) The ESB archive with the quickstart. Mmay need some tweaking - mainly to update the path to the audit log in jboss-esb.xml and to update agent.pkg.properties to point to the Drools package. (Also packaged inside the archive.)
Comment 1 Lukáš Petrovický 2011-01-14 04:30:32 EST
Attaching the above mentioned files. If necessary, I can also attach the Guvnor repository that can be used to generate the defaultPackage.pkg on-the-fly.
Comment 2 Lukáš Petrovický 2011-01-14 04:30:32 EST
Attachment: Added: Quickstart_business_rules_service5_jbqa-1855.esb
Attachment: Added: LATEST.drl
Attachment: Added: defaultPackage.pkg
Attachment: Added: ruleflowIntg.rf
Attachment: Added: subruleflowIntg.rf
Attachment: Added: business_rules_service5_jbqa-1855.log
Comment 5 Kevin Conner 2011-01-17 05:12:59 EST
Can you attach the full quickstart to this issue so that I can run it? 
Comment 6 Lukáš Petrovický 2011-01-17 06:40:25 EST
Attaching a version of the quickstart that should be easily runnable the usual way (ant deploy/runtest inside /samples/quickstarts).

When the functionality works, everything should proceed cleanly. With this bug however, ReviewMessage will throw an exception "Expectations are not met", telling the user that not every rule from the ruleflow has been fired.
Comment 7 Lukáš Petrovický 2011-01-17 06:40:25 EST
Attachment: Added: business_rules_service5_qe.tar.bz2
Comment 8 Lukáš Petrovický 2011-01-18 05:53:01 EST
Repository to import into BRMS to allow for testing the ruleflow.
Comment 9 Lukáš Petrovický 2011-01-18 05:53:01 EST
Attachment: Added: repository_export.zip
Comment 10 Kevin Conner 2011-01-18 10:47:50 EST
The difference between the BRMS and ESB quickstart executions is that BRMS is running this as a stateful session and this quickstart is executing as a stateless.

I believe that this should work with a stateless session but that there may be a bug in the StatelessKnowledgeSessionImpl class.

The execution fails because the event handler responsible for signalling the continuation of the process has been lost, a consequence of code within the StatelessKnowledgeSessionImpl.

Creation of the working memory (1) results in the initialisation of process listeners, including one triggered by the afterRuleFlowGroupDeactivated event.  Unfortunately newWorkingMemory() then replaces these listeners with those of the session (2).

1 ==>       ReteooWorkingMemory wm = new ReteooWorkingMemory( this.ruleBase.nextWorkingMemoryCounter(),
                                                              (SessionConfiguration) this.conf,
                                                              this.environment );

            // we don't pass the mapped listener wrappers to the session constructor anymore,
            // because they would be ignored anyway, since the wm already contains those listeners
            StatefulKnowledgeSessionImpl ksession = new StatefulKnowledgeSessionImpl( wm,
                                                                                      new KnowledgeBaseImpl( this.ruleBase ) );

            ((Globals) wm.getGlobalResolver()).setDelegate( this.sessionGlobals );
            wm.setKnowledgeRuntime( ksession );
            wm.setWorkingMemoryEventSupport( this.workingMemoryEventSupport );
            wm.setAgendaEventSupport( this.agendaEventSupport );
2 ==>       wm.setRuleFlowEventSupport( this.ruleFlowEventSupport );
Comment 11 Tihomir Surdilovic 2011-01-20 01:47:57 EST
branch for fix: https://svn.jboss.org/repos/labs/labs/jbossrules/soa_branches/BRMS-5.1-GA_SOA-2771/
Comment 12 Tihomir Surdilovic 2011-01-20 01:49:02 EST
fix committed to above branch. please retest (assigning back to Lukáš)
Comment 13 Lukáš Petrovický 2011-01-20 04:55:47 EST
Will have to wait for another SOA build.
Comment 14 Kevin Conner 2011-01-20 05:02:39 EST
I'll take this until we get it into a SOA build
Comment 15 Tihomir Surdilovic 2011-01-20 11:26:22 EST
Attached is the drools-core jar you can test with for now without having to build the branch. 
Comment 16 Tihomir Surdilovic 2011-01-20 11:26:23 EST
Attachment: Added: drools-core-5.1.0.BRMS.jar
Comment 17 Tihomir Surdilovic 2011-01-24 10:43:03 EST
Link: Added: This issue depends BRMS-542
Comment 18 Kevin Conner 2011-01-24 10:53:53 EST
Link: Added: This issue depends SOA-2841
Comment 19 Tihomir Surdilovic 2011-01-24 11:16:16 EST
added cleanup method to stateless session for ruleflow event listeners. new drools-core jar here
Comment 20 Tihomir Surdilovic 2011-01-24 11:16:17 EST
Attachment: Added: drools-core-5.1.0.BRMS.jar
Comment 21 Tihomir Surdilovic 2011-01-24 11:22:45 EST
Assigning back to Lukas for testing. You can build the branch or just use the attached drools-core-5.1.0.BRMS.jar (make sure to use the one from today).
Comment 22 Lukáš Petrovický 2011-01-25 06:21:58 EST
I verified with the latest bits that it is indeed fixed. Reassigning to Kevin to handle resolving the issue.
Comment 23 trev 2011-02-15 06:57:42 EST
included in drools pickup
Comment 24 Lukáš Petrovický 2011-02-16 05:18:53 EST
Verified fixed in CR1.
Comment 25 Dana Mison 2011-02-17 03:47:07 EST
Writer: Added: Darrin
Comment 26 Dana Mison 2011-02-17 03:47:35 EST
Release Notes Docs Status: Added: Documented as Resolved Issue
Release Notes Text: Added: RuleFlow would sometimes not execute correctly inside of the BusinessRulesProcessor ESB action.  This was because it was running in a stateless session instead of a stateful session as would be normally be expected.  The stateless session handling code has been updated to handle this type of scenario better.

Note You need to log in before you can comment on or make changes to this bug.