Re: [rules-users] Why does it seem like salience is being ignored? - SOLVED!

2012-07-16 Thread Edson Tirelli
   Glad to hear!

   If you can contribute your changes to drools-camel back, we can add it
to the codebase and maintain from now on. The whole drools community will
benefit.

   Thanks,
   Edson

On Mon, Jul 16, 2012 at 1:37 PM, Ladd  wrote:

> Many thanks to Edson, Wolfgang, and Mark.  Edson, your solution of
> modifying
> the drools-camel component to call fireAllRules() after each insert did the
> trick.  My salience values are now being honored.
>
> Thanks guys!!
>
> - Ladd
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/Why-does-it-seem-like-salience-is-being-ignored-tp4018669p4018716.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>



-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Why does it seem like salience is being ignored? - SOLVED!

2012-07-16 Thread Ladd
Many thanks to Edson, Wolfgang, and Mark.  Edson, your solution of modifying
the drools-camel component to call fireAllRules() after each insert did the
trick.  My salience values are now being honored.

Thanks guys!!

- Ladd

--
View this message in context: 
http://drools.46999.n3.nabble.com/Why-does-it-seem-like-salience-is-being-ignored-tp4018669p4018716.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Why does it seem like salience is being ignored?

2012-07-16 Thread Edson Tirelli
   Sorry, just saw your message. fireUntilHalt() will work in your use
case, as Mark mentioned. With fireUntilHalt(), as soon as a rule is
activated, it will fire if the agenda is idle. Because the topology of the
discrimination network is affected by the order of the rules in the file,
you end up having this different firing order depending on the order of the
rules in the file.

   The only way to work around this with the current version of Drools is
to call fireAllRules() after each insertion of an object into the working
memory and the current implementation of the Drools-Camel component does
not support that. If you want to do it yourself, it is quite easy:

1. Add support to a new parameter to tell the component to fireAllRules()
after inserting the object into the working memory:

https://github.com/droolsjbpm/droolsjbpm-integration/blob/master/drools-camel/src/main/java/org/drools/camel/component/DroolsEndpoint.java

2. Add the call to fireAllRules() after inserting the object in here:

https://github.com/droolsjbpm/droolsjbpm-integration/blob/master/drools-camel/src/main/java/org/drools/camel/component/DroolsInsertProducer.java


   Meanwhile, for the next version, we will need to add a staging area to
the agenda where the activations of a given propagation are added to the
agenda only when the whole propagation completes. This will fix the issue
for the general case.

   Edson

On Sat, Jul 14, 2012 at 2:18 PM, Ladd  wrote:

> I just tried the same test using 5.3.0 and got the same results.  Rule1b
> fires first.
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/Why-does-it-seem-like-salience-is-being-ignored-tp4018669p4018687.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>



-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Why does it seem like salience is being ignored?

2012-07-14 Thread Wolfgang Laun
No. DRL is free form, any white space is a separator.
-W


On 14/07/2012, Per Sterner  wrote:
> Hello,
>
> isn't there just mussing a '\n' before the word saliance in the line
>
> rule += "rule rule1a salience 100 \n";
>
> ?
>
> Regards,
>
>   Per Sterner
>
> Am 14.07.12 20:18, schrieb Ladd:
>> I just tried the same test using 5.3.0 and got the same results.  Rule1b
>> fires first.
>>
>> --
>> View this message in context:
>> http://drools.46999.n3.nabble.com/Why-does-it-seem-like-salience-is-being-ignored-tp4018669p4018687.html
>> Sent from the Drools: User forum mailing list archive at Nabble.com.
>> ___
>> rules-users mailing list
>> rules-users@lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>
>
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Why does it seem like salience is being ignored?

2012-07-14 Thread Per Sterner
Hello,

isn't there just mussing a '\n' before the word saliance in the line

rule += "rule rule1a salience 100 \n";

?

Regards,

  Per Sterner

Am 14.07.12 20:18, schrieb Ladd:
> I just tried the same test using 5.3.0 and got the same results.  Rule1b
> fires first.
>
> --
> View this message in context: 
> http://drools.46999.n3.nabble.com/Why-does-it-seem-like-salience-is-being-ignored-tp4018669p4018687.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>


___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Why does it seem like salience is being ignored?

2012-07-14 Thread Ladd
I just tried the same test using 5.3.0 and got the same results.  Rule1b
fires first.

--
View this message in context: 
http://drools.46999.n3.nabble.com/Why-does-it-seem-like-salience-is-being-ignored-tp4018669p4018687.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Why does it seem like salience is being ignored?

2012-07-14 Thread Wolfgang Laun
The session is running in a separate thread. There was an email on the
list, from Edson, just the other day, telling us about a race
condition in 5.4.0. Could be this is another effect of this bug.
"Every once in a while" is typical.

-W


On 14/07/2012, Ladd  wrote:
> I appreciate you trying to reproduce this W!!  I wonder what's different
> between my test and yours.  With the attached test classes and 5.4.0 I'm
> getting this output:
>
> rule1b: Just found message
> org.apache.camel.component.bean.pojomessage.Person@16274ea
> rule1a: Just found person Bob
> rule1b: Just found message
> org.apache.camel.component.bean.pojomessage.Person@186b2ca
> rule1a: Just found person Jim
>
> And every once in a while this output:
>
> rule1b: Just found message
> org.apache.camel.component.bean.pojomessage.Person@1dfee20
> rule1a: Just found person Bob
> rule1a: Just found person Jim
> rule1b: Just found message
> org.apache.camel.component.bean.pojomessage.Person@14a4067
>
> Thanks for the time guys!!
>
> - Ladd
>
> http://drools.46999.n3.nabble.com/file/n4018685/SalienceTest.java
> SalienceTest.java
> http://drools.46999.n3.nabble.com/file/n4018685/DroolsCamelTestSupport.java
> DroolsCamelTestSupport.java
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/Why-does-it-seem-like-salience-is-being-ignored-tp4018669p4018685.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Why does it seem like salience is being ignored?

2012-07-14 Thread Ladd
I appreciate you trying to reproduce this W!!  I wonder what's different
between my test and yours.  With the attached test classes and 5.4.0 I'm
getting this output:

rule1b: Just found message
org.apache.camel.component.bean.pojomessage.Person@16274ea
rule1a: Just found person Bob
rule1b: Just found message
org.apache.camel.component.bean.pojomessage.Person@186b2ca
rule1a: Just found person Jim

And every once in a while this output:

rule1b: Just found message
org.apache.camel.component.bean.pojomessage.Person@1dfee20
rule1a: Just found person Bob
rule1a: Just found person Jim
rule1b: Just found message
org.apache.camel.component.bean.pojomessage.Person@14a4067

Thanks for the time guys!!

- Ladd

http://drools.46999.n3.nabble.com/file/n4018685/SalienceTest.java
SalienceTest.java 
http://drools.46999.n3.nabble.com/file/n4018685/DroolsCamelTestSupport.java
DroolsCamelTestSupport.java 

--
View this message in context: 
http://drools.46999.n3.nabble.com/Why-does-it-seem-like-salience-is-being-ignored-tp4018669p4018685.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Why does it seem like salience is being ignored?

2012-07-14 Thread Wolfgang Laun
Both with 5.4.0 and 5.3.0 I can't reproduce the effect described by Ladd.
The inserts are of two Messages with Object body set to Person("...").
Knowledge Base is configured STREAM, but Message isn't an event.
-W


On 14/07/2012, Ladd  wrote:
> Thanks for the reply Mark!  However, in my test situation I'm never sending
> Person objects, only Message objects.  The payload of the message contains
> the Person object.  In my application there will be other types of payload
> objects though.
>
> In my test, Rule1a looks for messages containing persons:
>
>> rule += "rule rule1a salience 100 \n";
>> rule += "  when \n";
>> rule += "$m : Message( body.class == Person.class, $body : body ) \n";
>>
>> rule += "$p : Person() from $body \n";
>> rule += "  then \n";
>> rule += "System.err.println( \"rule1a: Just found person \" +
>> $p.getName() ); \n";
>> rule += "end\n";
>
> I tried your suggestion and rule1b never fired because Person never exists
> in memory (only messages that contain persons).
>
> My goal is to have a "catchall" rule that catches all messages that haven't
> been "caught" by other rules.  So every message in evaluates at least one
> rule to true.  I figured rule with constraint "when Message()" with a low
> salience would do that.  Since 1a and 1b both evaluate to true in my test,
> I
> figured adjusting the salience would adjust the firing order.
>
> Thanks for any insight you can offer!!!
>
> - Ladd
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/Why-does-it-seem-like-salience-is-being-ignored-tp4018669p4018682.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Why does it seem like salience is being ignored?

2012-07-14 Thread Ladd
Thanks for the reply Mark!  However, in my test situation I'm never sending
Person objects, only Message objects.  The payload of the message contains
the Person object.  In my application there will be other types of payload
objects though.

In my test, Rule1a looks for messages containing persons:

> rule += "rule rule1a salience 100 \n"; 
> rule += "  when \n"; 
> rule += "$m : Message( body.class == Person.class, $body : body ) \n"; 
> rule += "$p : Person() from $body \n"; 
> rule += "  then \n"; 
> rule += "System.err.println( \"rule1a: Just found person \" +
> $p.getName() ); \n"; 
> rule += "end\n"; 

I tried your suggestion and rule1b never fired because Person never exists
in memory (only messages that contain persons).

My goal is to have a "catchall" rule that catches all messages that haven't
been "caught" by other rules.  So every message in evaluates at least one
rule to true.  I figured rule with constraint "when Message()" with a low
salience would do that.  Since 1a and 1b both evaluate to true in my test, I
figured adjusting the salience would adjust the firing order.

Thanks for any insight you can offer!!!

- Ladd

--
View this message in context: 
http://drools.46999.n3.nabble.com/Why-does-it-seem-like-salience-is-being-ignored-tp4018669p4018682.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Why does it seem like salience is being ignored?

2012-07-13 Thread Mark Proctor
in fireUntilHalt for salience to take effect the rules must be in 
conflict; i.e. on the agenda at the same time, normally due to 
activation being created from the same working memory action.

If you insert message and later insert person, the message will react 
straight away and fire; as there is nothing cuasing it to wait to become 
in conflict with other rules. Try adding an "exists Person()" pattern to 
rule1b.

Mark
On 13/07/2012 18:37, Ladd wrote:
> I'm using drools-camel 5.4.0.Final.  ksession is stateful, I'm in STREAM
> mode, and rules are fired with fireUntilHalt().
>
> My test route is:
>
> from( "direct:test-message" ).to(
> "drools://node/ksession1?action=insertMessage" );
>
> I'm sending my objects into the engine like so:
>
> template.sendBody( "direct:test-message", new Person( "Bob" ) );
> template.sendBody( "direct:test-message", new Person( "Jim" ) );
>
> I have two rules that I'd like to fire in a specific order (1a followed by
> 1b).
>
> If I define rule1a first in my drl it fires first as I would expect (with or
> without a salience specified).  But if I define rule1b first, that fires
> first even though rule1a has a higher salience.
>
> Here are my two rules / test cases and the results:
>
> *Scenario 1 (rule1a first first as I want it to):*
>
> rule += "rule rule1a salience 100 \n";
> rule += "  when \n";
> rule += "$m : Message( body.class == Person.class, $body : body ) \n";
> rule += "$p : Person() from $body \n";
> rule += "  then \n";
> rule += "System.err.println( \"rule1a: Just found person \" +
> $p.getName() ); \n";
> rule += "end\n";
>  
> rule += "rule rule1b\n";
> rule += "  when \n";
> rule += "$m : Message() \n";
> rule += "  then \n";
> rule += "System.err.println( \"rule1b: Just found message \" +
> $m.getBody().toString() ); \n";
> rule += "end\n";
>
> *Output:*
> rule1a: Just found person Bob
> rule1b: Just found message
> org.apache.camel.component.bean.pojomessage.Person@b49448
> rule1a: Just found person Jim
> rule1b: Just found message
> org.apache.camel.component.bean.pojomessage.Person@f4e9d3
>
> *Scenario 2 (rule1b fires first even through rule1a has a higher salience):*
>
> rule += "rule rule1b\n";
> rule += "  when \n";
> rule += "$m : Message() \n";
> rule += "  then \n";
> rule += "System.err.println( \"rule1b: Just found message \" +
> $m.getBody().toString() ); \n";
> rule += "end\n";
>  
> rule += "rule rule1a salience 100 \n";
> rule += "  when \n";
> rule += "$m : Message( body.class == Person.class, $body : body ) \n";
> rule += "$p : Person() from $body \n";
> rule += "  then \n";
> rule += "System.err.println( \"rule1a: Just found person \" +
> $p.getName() ); \n";
> rule += "end\n";
>
> *Output:*
> rule1b: Just found message
> org.apache.camel.component.bean.pojomessage.Person@1133fd6
> rule1a: Just found person Bob
> rule1b: Just found message
> org.apache.camel.component.bean.pojomessage.Person@ca425c
> rule1a: Just found person Jim
>
> Something simple I'm sure.  Any pointers to get my salience working?
>
> Thanks for taking the time to help me out!!
>
> - Ladd
>
> --
> View this message in context: 
> http://drools.46999.n3.nabble.com/Why-does-it-seem-like-salience-is-being-ignored-tp4018669.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users


___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users