[rules-users] Replacement for eval

Nirmal Fernando nirmal070125 at gmail.com
Tue Nov 16 23:32:07 EST 2010


Thanks for the replies!

I observed that the action of a rule not get executed straight after that
rule activated.

Say my rules are following:

rule "Hello World"
    when
    then
        System.out.println( "hello world" );
end

rule "GoodBye"
    when
        Message( status == Message.GOODBYE, myMessage : message )
    then
        System.out.println("good bye");
end

If I have set up my Message class such that it will fire the "GoodBye" rule,
my output is:

good bye
hello world

What I wanna know whether this is the expected behaviour? (Since normally I
expect the action of that particular rule to be executed straight after it's
fired.)

Am I missing something here?

Thanks.


2010/11/16 Greg Barton <greg_barton at yahoo.com>

> If you use bean property conventions for naming your methods you can use a
> regular condition element.  for instance, you could rename
> emptyMessageFinder() to isMessageFound() or getMessageFound() and your
> condition would look like this:
>
> when
>   m : Message(messageFound == true)
> then
> ...
> end
>
> And when you do this the rete is used, birds sing in the trees, and world
> peace will be declared.
>
> GreG
>
> On Nov 16, 2010, at 5:37, Nirmal Fernando <nirmal070125 at gmail.com> wrote:
>
> Hi,
>
> I have two questions.
>
> 1) Is there any other way/method in Drools to test the truth value of a
> condition other than "eval"?
> In almost all rules of my application needs to test conditions, and it
> takes ages to run using "eval".
>
> 2) Say I have a java method which returns a boolean, and I have used it
> within an "eval" function. (eg: eval(message.emptyMessageFinder()) )
> This "emptyMessageFinder()" method will return a "boolean" if there's an
> empty message. This function is containing many loops and recursive
> operations.
>
> Will I get a performance improvement if I alternate the above such that the
> "emptyMessageFinder()" method sets a boolean attribute (anyEmptyMessage)
> in the Message class to true and false, and I'm using following in my drl.
>
> when
>    m: Message()
>    m.emptyMessageFinder()
>    eval(m.anyEmptyMessage)  //can I use eval here??
> ......
>
> If someone can answer these questions it would be a great help!
>
> Thank you in advance!
>
> --
> Best Regards,
> Nirmal
>
> C.S.Nirmal J. Fernando
> Department of Computer Science & Engineering,
> Faculty of Engineering,
> University of Moratuwa,
> Sri Lanka.
>
> Blog:  <http://nirmalfdo.blogspot.com/>http://nirmalfdo.blogspot.com/
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>


-- 
Best Regards,
Nirmal

C.S.Nirmal J. Fernando
Department of Computer Science & Engineering,
Faculty of Engineering,
University of Moratuwa,
Sri Lanka.

Blog: http://nirmalfdo.blogspot.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20101117/8a340a20/attachment.html 


More information about the rules-users mailing list