Re: [rules-users] duration attribute & other rule language features issue

2011-12-06 Thread prashant.badhe
Changing pseudo-clock to "realtime" solves both timer() and @expires issues.

Also, the java.lang.ClassCastException on updating fact from rule RHS is
also not observed anymore.
Looks like the ClockTypeOption for kSession is a important one.

Thanks for all your replies.
-Prashant

--
View this message in context: 
http://drools.46999.n3.nabble.com/rules-users-duration-attribute-other-rule-language-features-issue-tp3536857p3564050.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] duration attribute & other rule language features issue

2011-11-29 Thread Wolfgang Laun
ution on timer() issue .
>
> One more thing I observed today is (without timer() off course), when I put
> following 3 lines in RHS of rule:
> /$alert.setType("test type");
> $alert.setComponentId("YYY");
> update($alert);/
>
>  then sometimes I get following exception at /update($alert)/:
> *java.lang.ClassCastException: org.drools.common.DefaultFactHandle cannot be
> cast to org.drools.common.EventFactHandle*
> org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:201)
> org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:145)
> org.drools.common.NamedEntryPoint.update(NamedEntryPoint.java:251)
> org.drools.base.DefaultKnowledgeHelper.update(DefaultKnowledgeHelper.java:183)
> org.drools.base.DefaultKnowledgeHelper.update(DefaultKnowledgeHelper.java:196)
> abc.xyz.alertProcessor.Rule_check_timer_attribute_0.defaultConsequence(Rule_check_timer_attribute_0.java:27)
> abc.xyz.alertProcessor.Rule_check_timer_attribute_0DefaultConsequenceInvoker.evaluate(Rule_check_timer_attribute_0DefaultConsequenceInvoker.java:35)
> org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:917)
> org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:856)
> org.drools.common.DefaultAgenda.fireUntilHalt(DefaultAgenda.java:1049)
> org.drools.common.AbstractWorkingMemory.fireUntilHalt(AbstractWorkingMemory.java:829)
> org.drools.common.AbstractWorkingMemory.fireUntilHalt(AbstractWorkingMemory.java:805)
> org.drools.impl.StatefulKnowledgeSessionImpl.fireUntilHalt(StatefulKnowledgeSessionImpl.java:230)
>
> Does this mean, modifying value of fact members in RHS is not expected? , &
> if modified then drools may not find that object in its pool for update() &
> retract() (based on the EventFactHandle)?
>
> - Prashant
>
> --
> View this message in context: 
> http://drools.46999.n3.nabble.com/rules-users-duration-attribute-other-rule-language-features-issue-tp3536857p3545080.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] duration attribute & other rule language features issue

2011-11-29 Thread prashant.badhe
org.drools.base.DefaultKnowledgeHelper.update(DefaultKnowledgeHelper.java:196)
abc.xyz.alertProcessor.Rule_check_timer_attribute_0.defaultConsequence(Rule_check_timer_attribute_0.java:27)
abc.xyz.alertProcessor.Rule_check_timer_attribute_0DefaultConsequenceInvoker.evaluate(Rule_check_timer_attribute_0DefaultConsequenceInvoker.java:35)
org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:917)
org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:856)
org.drools.common.DefaultAgenda.fireUntilHalt(DefaultAgenda.java:1049)
org.drools.common.AbstractWorkingMemory.fireUntilHalt(AbstractWorkingMemory.java:829)
org.drools.common.AbstractWorkingMemory.fireUntilHalt(AbstractWorkingMemory.java:805)
org.drools.impl.StatefulKnowledgeSessionImpl.fireUntilHalt(StatefulKnowledgeSessionImpl.java:230)

Does this mean, modifying value of fact members in RHS is not expected? , &
if modified then drools may not find that object in its pool for update() &
retract() (based on the EventFactHandle)?

- Prashant

--
View this message in context: 
http://drools.46999.n3.nabble.com/rules-users-duration-attribute-other-rule-language-features-issue-tp3536857p3545080.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] duration attribute & other rule language features issue

2011-11-28 Thread Wolfgang Laun
It seems that a full definition of the semantics of @expires is still
missing from the Fusion manual.

"After that time, assuming no rule *still needs the event*, the engine will
expire and remove the event from the session automatically." (Emphasis by
me.)

So, when does a rule "need an event"? This is a very iffy definition.

Consider:
   when
  Event()
   then
This rule certainly "needs" an Event fact, but does it still need it after
the first firing? Not unless Event() is modified, which might happen
elsewhere.

In the case of a timer() being added to a rule, there is a similar dilemma.
A rule like
  rule
timer(int: 5s)
  when
Event()
  then
does and, simultaneously does not, "need" an Event() fact. If Event() is
retracted after less than 5s, the rule should not fire - so the rule does
not "need" the fact. OTOH, its timed firing depends on the presence of an
Event() - so the rule "needs" the fact.

You can easily thwart the algorithm that determines "is needed":

rule "check timer attribute"
timer (int: 5s 1s)
when
$alert : Object( eval($alert instanceof Alert) ) from entry-point
"EventStream"
then
 System.out.println( ((Alert)$alert).getId() +
" time: " +
(Calendar.getInstance().getTimeInMillis()));
end

-W



On 28 November 2011 07:32, prashant.badhe  wrote:

> Here is the complete rule that we trying out with 'timer' & '@expires' :
>
> ~
> package xyz;
>
> import abc.Alert;
> import abc.CResult;
>
> import java.util.regex.Matcher;
> import java.util.regex.Pattern;
> import java.util.ArrayList;
> import java.util.HashMap;
> import java.util.Iterator;
> import java.util.Date;
> import java.util.Calendar;
> import java.util.Timer;
>
> declare Alert
>@role( event )
>@expires( 30s )
> end
>
> declare CResult
>@role( event )
>@expires( 30s )
> end
>
> rule "check timer attribute"
>agenda-group "xyz"
>auto-focus true
>no-loop
>salience 140
>   timer (int: 5s)
>//duration ( 5s )
>
>when
>$alert : Alert( $alertId:id ) from entry-point "EventStream"
>then
>System.out.println("Inside RHS...[alert=" + $alert.getId()
> + "]
> [Time: " + (Calendar.getInstance().getTimeInMillis()));
>
> end
> ~
>
> We are trying this out on Drools 5.3.0 stateful knowledge session operating
> in stream mode.
>
> The above rule is not firing on inserting Alert fact. If I comment line
> 'timer (int: 5s 5s)' then it starts firing.
>
> About the @expires, our assumption is Alert fact inserted is not expiring,
> as the count returned by getFactCount() on WM entrypoint object is returned
> as 1 even after a thread sleep of more than 60 seconds post the rule
> firing.
>
> Please correct us if this assumption is wrong or something more is required
> for @expires to work. Similarly for timer(int: 5s) let us know what is
> wrong.
>
> Does the facts that are expired remains in WM but are not evaluated for any
> new facts/rules inserted in WM OR they are removed from WM?
>
> -Prashant
>
>
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/rules-users-duration-attribute-other-rule-language-features-issue-tp3536857p3541469.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] duration attribute & other rule language features issue

2011-11-27 Thread prashant.badhe
Here is the complete rule that we trying out with 'timer' & '@expires' :

~
package xyz;

import abc.Alert;
import abc.CResult;

import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Date;
import java.util.Calendar;
import java.util.Timer;

declare Alert
@role( event )
@expires( 30s )
end

declare CResult
@role( event )
@expires( 30s )
end

rule "check timer attribute"
agenda-group "xyz"
auto-focus true
no-loop
salience 140
   timer (int: 5s)
//duration ( 5s )

when
$alert : Alert( $alertId:id ) from entry-point "EventStream"
then
System.out.println("Inside RHS...[alert=" + $alert.getId() + "]
[Time: " + (Calendar.getInstance().getTimeInMillis()));

end
~

We are trying this out on Drools 5.3.0 stateful knowledge session operating
in stream mode.

The above rule is not firing on inserting Alert fact. If I comment line
'timer (int: 5s 5s)' then it starts firing.

About the @expires, our assumption is Alert fact inserted is not expiring,
as the count returned by getFactCount() on WM entrypoint object is returned
as 1 even after a thread sleep of more than 60 seconds post the rule firing.

Please correct us if this assumption is wrong or something more is required
for @expires to work. Similarly for timer(int: 5s) let us know what is
wrong.

Does the facts that are expired remains in WM but are not evaluated for any
new facts/rules inserted in WM OR they are removed from WM?

-Prashant




--
View this message in context: 
http://drools.46999.n3.nabble.com/rules-users-duration-attribute-other-rule-language-features-issue-tp3536857p3541469.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] duration attribute & other rule language features issue

2011-11-26 Thread Wolfgang Laun
Rule timers using int: or cron: work pretty much as described in the Expert
documentation.

With 5.1.1, there was an issue with timer(int:...) due to a parser bug, see
JBRULES-2778 

Also, @expires with declare is working. Notice, though, that it is not
alway immediately apparent why a fact is not retracted after the indicated
time. Please provide a full working example where you find that it does not
work.

-W


2011/11/25 Prashant Badhe 

> Hi,
>
> we were using drools engine 5.0.1 version with rules having 'duration',
> 'agenda-group' attributes and now we want to upgrade drools engine to 5.1.1
> or latest 5.3.0 but we find 'duration' feature not working. What are the
> equivalents of those features in 5.1.1 and in 5.3.0?
>
>
> From drools-expert document, 'duration' seems as deprecated with 'timer'.
> But even 'timer' is not working. Putting 'timer' attribute as:
>
>
> rule "test timer attribute"
> agenda-group "enrichment"
> auto-focus true
> no-loop
> salience 140
> timer ( int: 5s )
> //duration ( 5000 )
> when
>   ..
>then
>  ..
>end
>
> gives "Error: java.lang.ArrayStoreException" Drools compilation error.
> "timer ( 5s )" compiles, but the rule never fires.
>
> We are also planning to use @expires in declare. But facts are not seems
> to be expiring.
>
> What am I missing here? What are the equivalent for 'duration' in
> 5.1.1/5.3.0 and how to use @expires in declare?
> Please point us to some sample rules that uses these semantics and are
> working.
>
> Thanks in advance,
> Prashant B.
>
> ___
> 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] duration attribute & other rule language features issue

2011-11-25 Thread Prashant Badhe
Hi,

we were using drools engine 5.0.1 version with rules having 'duration',
'agenda-group' attributes and now we want to upgrade drools engine to 5.1.1
or latest 5.3.0 but we find 'duration' feature not working. What are the
equivalents of those features in 5.1.1 and in 5.3.0?


>From drools-expert document, 'duration' seems as deprecated with 'timer'.
But even 'timer' is not working. Putting 'timer' attribute as:


rule "test timer attribute"
agenda-group "enrichment"
auto-focus true
no-loop
salience 140
timer ( int: 5s )
//duration ( 5000 )
when
  ..
   then
 ..
   end

gives "Error: java.lang.ArrayStoreException" Drools compilation error.
"timer ( 5s )" compiles, but the rule never fires.

We are also planning to use @expires in declare. But facts are not seems to
be expiring.

What am I missing here? What are the equivalent for 'duration' in
5.1.1/5.3.0 and how to use @expires in declare?
Please point us to some sample rules that uses these semantics and are
working.

Thanks in advance,
Prashant B.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users