[jboss-jira] [JBoss JIRA] Closed: (JBRULES-313) Add halt/run commands
Edson Tirelli (JIRA)
jira-events at lists.jboss.org
Wed Jun 27 20:08:09 EDT 2007
[ http://jira.jboss.com/jira/browse/JBRULES-313?page=all ]
Edson Tirelli closed JBRULES-313.
---------------------------------
Resolution: Done
Halt command is implemented.
Just call from a rule consequence:
drools.halt();
Or from your application:
workingMemory.halt();
It will finish the execution of the current rule (in case it is executing one) and stop firing. To restart firing, just call fireAllRules() again.
Test case here:
http://anonsvn.labs.jboss.com/labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/integrationtests/test_halt.drl
> Add halt/run commands
> ---------------------
>
> Key: JBRULES-313
> URL: http://jira.jboss.com/jira/browse/JBRULES-313
> Project: JBoss Rules
> Issue Type: Feature Request
> Security Level: Public(Everyone can see)
> Environment: any
> Reporter: Jacek Jarmulak
> Assigned To: Edson Tirelli
> Fix For: 4.0.0.MR4
>
>
> I have made a small modification to WorkingMemory and AbstractWorkingMemory that allows me to pause and the restart rule firing.
> The change consists of adding a boolean isPaused flag (plus gettter and setter methods) which is then inspected in the while loop of the fireAllRules method as follows
> public synchronized void fireAllRules(final AgendaFilter agendaFilter) throws FactException {
> if ( !this.firing ) {
> try {
> this.firing = true;
> while ( !this.isPaused() && this.agenda.fireNextItem( agendaFilter ) ) {
> ;
> }
> } finally {
> this.firing = false;
> }
> }
> }
> What is this good for?
> It lets me stop rule firing from within some rule, e.g. when I want to execute an external call.
> The rule sets up the call and then calls setPaused(true) on WorkingMemory.
> Once fireAllRules exits, an external process executes the call, possibly asserting some facts into WorkingMemory
> and then calls setPaused(false) and calls fireAllRules again.
> Why not execute the call directly from the rule?
> Because in my application the execution might take long time, and I want to have an option to move the WorkingMemory out of RAM,
> possibly moving it to another app server to continue firing after the externall call processing has completed.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the jboss-jira
mailing list