Bug 780362 (SOA-2771) - Ruleflow broken inside BusinessRulesProcessor
Summary: Ruleflow broken inside BusinessRulesProcessor
Keywords:
Status: CLOSED NEXTRELEASE
Alias: SOA-2771
Product: JBoss Enterprise SOA Platform 5
Classification: JBoss
Component: JBossESB
Version: 5.1.0.ER6,5.1.0.ER7
Hardware: Unspecified
OS: Unspecified
urgent
urgent
Target Milestone: ---
: 5.1.0 GA,5.1.0.CR1
Assignee: Kevin Conner
QA Contact:
URL: http://jira.jboss.org/jira/browse/SOA...
Whiteboard:
Depends On: BRMS-542 SOA-2841
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-01-14 09:27 UTC by Lukáš Petrovický
Modified: 2011-02-17 08:47 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Fedora 14, OpenJDK.
Last Closed: 2011-02-17 08:47:35 UTC
Type: Bug
Embargoed:


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


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker SOA-2771 0 None None None Never

Description Lukáš Petrovický 2011-01-14 09:27:00 UTC
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 09:30:32 UTC
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 09:30:32 UTC
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 10:12:59 UTC
Can you attach the full quickstart to this issue so that I can run it? 

Comment 6 Lukáš Petrovický 2011-01-17 11:40:25 UTC
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 11:40:25 UTC
Attachment: Added: business_rules_service5_qe.tar.bz2


Comment 8 Lukáš Petrovický 2011-01-18 10:53:01 UTC
Repository to import into BRMS to allow for testing the ruleflow.

Comment 9 Lukáš Petrovický 2011-01-18 10:53:01 UTC
Attachment: Added: repository_export.zip


Comment 10 Kevin Conner 2011-01-18 15:47:50 UTC
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(),
                                                              this.ruleBase,
                                                              (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 06:47:57 UTC
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 06:49:02 UTC
fix committed to above branch. please retest (assigning back to Lukáš)

Comment 13 Lukáš Petrovický 2011-01-20 09:55:47 UTC
Will have to wait for another SOA build.

Comment 14 Kevin Conner 2011-01-20 10:02:39 UTC
I'll take this until we get it into a SOA build

Comment 15 Tihomir Surdilovic 2011-01-20 16:26:22 UTC
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 16:26:23 UTC
Attachment: Added: drools-core-5.1.0.BRMS.jar


Comment 17 Tihomir Surdilovic 2011-01-24 15:43:03 UTC
Link: Added: This issue depends BRMS-542


Comment 18 Kevin Conner 2011-01-24 15:53:53 UTC
Link: Added: This issue depends SOA-2841


Comment 19 Tihomir Surdilovic 2011-01-24 16:16:16 UTC
added cleanup method to stateless session for ruleflow event listeners. new drools-core jar here

Comment 20 Tihomir Surdilovic 2011-01-24 16:16:17 UTC
Attachment: Added: drools-core-5.1.0.BRMS.jar


Comment 21 Tihomir Surdilovic 2011-01-24 16:22:45 UTC
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 11:21:58 UTC
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 11:57:42 UTC
included in drools pickup

Comment 24 Lukáš Petrovický 2011-02-16 10:18:53 UTC
Verified fixed in CR1.

Comment 25 Dana Mison 2011-02-17 08:47:07 UTC
Writer: Added: Darrin


Comment 26 Dana Mison 2011-02-17 08:47:35 UTC
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.