[rules-users] How can I use retract in action or exception handler?

Mark Proctor mproctor at codehaus.org
Thu Jun 3 01:57:25 EDT 2010


On 02/06/2010 23:08, EugeneP wrote:
> Good afternoon
>
> How can I use retract in action or exception handler?
> For example,
> 0. I have a flow diagram;
> 1. in some node the fact Person( age == 10) is added to the working memory
> by 'insert';
> 2. after some steps, the split node pass the control to the action-node
> 3. and in this action I need to retract this fact. How?!
> The action MVEL code like:
>
> $t : Person( age==10)
> retract($t)
>    
That would not be any valid MVEL or Java; you have mixed a rule LHS nd a 
rule RHS - neither of which are valid for an action. Firstly you'll need 
access to the facthandle, so you'll need to store that as a variable 
some how. Then you can do
kcontext.knowledgeRuntime.retract( factHandle );
> - does not work b/c of knowledge base errors:
> "Could not parse knowledge..."
> "Unable to build expression for action..."
> "java.lang.Class cannot be cast to org.mvel2.util.MethodStub :
> org.drools.lang.descr.ProcessDescr at fa54fe"
>
> Thanks,
>      Eugene P
>    





More information about the rules-users mailing list