Re: [rules-users] Initial rule delay

2012-06-07 Thread Paul R.
Thanks Wolfgang, that works for me.

On Thu, Jun 7, 2012 at 1:14 PM, Wolfgang Laun wrote:

> The several distinct activations created from the rule fire once. To
> see this, add this snippet:
>
>session.addEventListener( new DefaultAgendaEventListener() {
>public void beforeActivationFired(BeforeActivationFiredEvent event)
> {
>super.beforeActivationFired( event );
>System.out.println( "EVENT FIRED: " + event );
>}
>public void activationCreated(ActivationCreatedEvent event) {
>super.activationCreated( event );
>System.out.println( "EVENT CREATED: " + event );
>}
>  } );
>
> Also, continue after the loop inserting the events:
>
>   for (long i = 1; i <= 100; i++) {
>clock.advanceTime(1, TimeUnit.SECONDS);
>session.setGlobal("time", clock.getCurrentTime());
>session.fireAllRules();
>}
>
> Your wish to have the first activation delayed by the timer's initial
> delay is always granted. But you can't have the very same rule firing
> as if there were no timer at all.
>
> So I guess you'll have to use the approach where a trigger fact is
> inserted.
>
> declare Trigger
> end
>
> rule FirstFoo
> timer (int: 5s)
> when
>not Trigger()
>Foo() from entry-point EntryPoint
> then
>insert( new Trigger() );
> end
>
> rule test
> when
>   Trigger()
>   $count : Number() from accumulate(
>   $f : Foo() over window:time(5000ms) from entry-point EntryPoint,
>   count($f) )
> then
>   System.out.println("count = " + $count + ", time = " + time + "ms");
> end
>
> Simple enough, I'd say.
> -W
>
>
> On 07/06/2012, Paul R.  wrote:
> > Hi Wolfgang,
> >
> > I've attached a simple test case, which demonstrates the repetitions. If
> > you run it, you'll see that the rule fires 3 times. [Tested in 5.4]
> >
> > count = 5, time = 5000ms
> > count = 5, time = 1ms
> > count = 5, time = 15000ms
> >
> > Changing the repeat-interval to 0 has identical results. Changing to a
> > negative number [suggested earlier] causes an infinite loop in Drools.
> >
> > To clarify, what I'm trying to do is block the rule from firing for the
> > first 5 seconds and then fire normally after that ( as if there was no
> > timer ). For example. The output I'm trying to achieve (not necessarily
> > with timers) is:
> >
> > count = 5, time = 5000ms
> > count = 5, time = 6000ms
> > count = 5, time = 7000ms
> > count = 5, time = 8000ms
> > count = 5, time = 9000ms
> > count = 5, time = 1ms
> > count = 5, time = 11000ms
> > count = 5, time = 12000ms
> > count = 5, time = 13000ms
> > count = 5, time = 14000ms
> > count = 5, time = 15000ms
> >
> > Thanks & Regards,
> >
> > Paul
> >
> > On Thu, Jun 7, 2012 at 7:41 AM, Wolfgang Laun
> > wrote:
> >
> >> On 07/06/2012, Mark Proctor  wrote:
> >> > On 06/06/2012 18:39, Vincent LEGENDRE wrote:
> >> >> try with a negative number ?
> >> > I would ommit the number all together. I suspect what 0 does is
> >> > schedule
> >> > with intervals of 0s, thus it fires straight away.
> >> > timer(int: 5s)
> >>
> >> @myself: I really should RFTM before proposing risky (if working)
> >> workarounds.
> >>
> >> The OP's claim  "if the repeat interval is omitted, it uses the
> >> initial delay as the repeat interval" is, untrue; DRL timer's
> >> definition is in line with all similar APIs and definitions, i.e.,
> >> when the repeat interval is omitted, then it's a one shot timer.
> >>
> >> @Paul: As I wrote in a previous mail - there's got to be another
> >> effect that causes the repetitions. Note that a live timer is
> >> connected to an *activation*, which isn't the same as being connected
> >> to a *rule*:
> >>   1 rule - n activations - n timers - x firings.
> >>
> >> -W
> >>
> >> >
> >> > Mark
> >> >>
> >> >> - Original Message -
> >> >> From: "Paul R."
> >> >> To: "Rules Users List"
> >> >> Sent: Mercredi 6 Juin 2012 19:26:22
> >> >> Subject: Re: [rules-users] Initial rule delay
> >> >>
> >> >>
> >> >> Thanks Wolfgang, but setting the repeat

Re: [rules-users] Initial rule delay

2012-06-07 Thread Paul R.
Hi Wolfgang,

I've attached a simple test case, which demonstrates the repetitions. If
you run it, you'll see that the rule fires 3 times. [Tested in 5.4]

count = 5, time = 5000ms
count = 5, time = 1ms
count = 5, time = 15000ms

Changing the repeat-interval to 0 has identical results. Changing to a
negative number [suggested earlier] causes an infinite loop in Drools.

To clarify, what I'm trying to do is block the rule from firing for the
first 5 seconds and then fire normally after that ( as if there was no
timer ). For example. The output I'm trying to achieve (not necessarily
with timers) is:

count = 5, time = 5000ms
count = 5, time = 6000ms
count = 5, time = 7000ms
count = 5, time = 8000ms
count = 5, time = 9000ms
count = 5, time = 1ms
count = 5, time = 11000ms
count = 5, time = 12000ms
count = 5, time = 13000ms
count = 5, time = 14000ms
count = 5, time = 15000ms

Thanks & Regards,

Paul

On Thu, Jun 7, 2012 at 7:41 AM, Wolfgang Laun wrote:

> On 07/06/2012, Mark Proctor  wrote:
> > On 06/06/2012 18:39, Vincent LEGENDRE wrote:
> >> try with a negative number ?
> > I would ommit the number all together. I suspect what 0 does is schedule
> > with intervals of 0s, thus it fires straight away.
> > timer(int: 5s)
>
> @myself: I really should RFTM before proposing risky (if working)
> workarounds.
>
> The OP's claim  "if the repeat interval is omitted, it uses the
> initial delay as the repeat interval" is, untrue; DRL timer's
> definition is in line with all similar APIs and definitions, i.e.,
> when the repeat interval is omitted, then it's a one shot timer.
>
> @Paul: As I wrote in a previous mail - there's got to be another
> effect that causes the repetitions. Note that a live timer is
> connected to an *activation*, which isn't the same as being connected
> to a *rule*:
>   1 rule - n activations - n timers - x firings.
>
> -W
>
> >
> > Mark
> >>
> >> - Original Message -
> >> From: "Paul R."
> >> To: "Rules Users List"
> >> Sent: Mercredi 6 Juin 2012 19:26:22
> >> Subject: Re: [rules-users] Initial rule delay
> >>
> >>
> >> Thanks Wolfgang, but setting the repeat-interval to 0 seems to have the
> >> same effect as omitting the repeat-interval [Tested in 5.1&  5.4].
> >>
> >>
> >> Thanks Vincent, this seems to work. However I was hoping for a simpler
> >> solution :)
> >>
> >>
> >> - Paul
> >>
> >> On Wed, Jun 6, 2012 at 5:06 PM, Vincent LEGENDRE<
> >> vincent.legen...@eurodecision.com>  wrote:
> >>
> >>
> >> Yes of course ...
> >> Simpler this way ...
> >>
> >>
> >> - Original Message -
> >> From: "Wolfgang Laun"<  wolfgang.l...@gmail.com>
> >> To: "Rules Users List"<  rules-users@lists.jboss.org>
> >>
> >>
> >> Sent: Mercredi 6 Juin 2012 18:02:40
> >> Subject: Re: [rules-users] Initial rule delay
> >>
> >> Try:
> >> timer( int:  0 )
> >> -W
> >>
> >> On 06/06/2012, Paul R.<  reverselo...@gmail.com>  wrote:
> >>> Hi,
> >>>
> >>> I'm looking for a way to delay a rules initial execution? In the
> >>> following
> >>> example, I would like to prevent the rule from firing when the first
> >>> "Foo"
> >>> event is inserted into the working memory.
> >>>
> >>> rule "DelayTest" when $n : Number() from accumulate( $f : Foo() over
> >>> window:time(10s) count($f) ) then // bla end
> >>>
> >>> The timer attribute seems to almost support what I'm looking for, i.e.
> >>> it
> >>> allows for an initial-delay to be specified; but if the repeat interval
> >>> is
> >>> omitted, it uses the initial delay as the repeat interval.
> >>>
> >>> timer ( int:  ? )
> >>>
> >>> In my case I would like to block the execution of the rule for an
> >>> "initial-delay" period, but after that time has elapsed the rule should
> >>> fire when every time a new "Foo" event is inserted into the working
> >>> memory.
> >>> What is the recommended way to do this?
> >>>
> >>> Thanks&  Regards,
> >>>
> >>> Paul
> >>>
> >> ___
> >> rules-users mailing list
> >

Re: [rules-users] Initial rule delay

2012-06-06 Thread Paul R.
Thanks Wolfgang, but setting the repeat-interval to 0 seems to have the
same effect as omitting the repeat-interval [Tested in 5.1 & 5.4].

Thanks Vincent, this seems to work. However I was hoping for a simpler
solution :)

- Paul

On Wed, Jun 6, 2012 at 5:06 PM, Vincent LEGENDRE <
vincent.legen...@eurodecision.com> wrote:

> Yes of course ...
> Simpler this way ...
>
> - Original Message -
> From: "Wolfgang Laun" 
> To: "Rules Users List" 
> Sent: Mercredi 6 Juin 2012 18:02:40
> Subject: Re: [rules-users] Initial rule delay
>
> Try:
>   timer( int:  0 )
> -W
>
> On 06/06/2012, Paul R.  wrote:
> > Hi,
> >
> > I'm looking for a way to delay a rules initial execution? In the
> following
> > example, I would like to prevent the rule from firing when the first
> "Foo"
> > event is inserted into the working memory.
> >
> > rule "DelayTest" when $n : Number() from accumulate( $f : Foo() over
> > window:time(10s) count($f) ) then // bla end
> >
> > The timer attribute seems to almost support what I'm looking for, i.e. it
> > allows for an initial-delay to be specified; but if the repeat interval
> is
> > omitted, it uses the initial delay as the repeat interval.
> >
> > timer ( int:  ? )
> >
> > In my case I would like to block the execution of the rule for an
> > "initial-delay" period, but after that time has elapsed the rule should
> > fire when every time a new "Foo" event is inserted into the working
> memory.
> > What is the recommended way to do this?
> >
> > Thanks & Regards,
> >
> > Paul
> >
> ___
> 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


[rules-users] Initial rule delay

2012-06-06 Thread Paul R.
Hi,

I'm looking for a way to delay a rules initial execution? In the following
example, I would like to prevent the rule from firing when the first "Foo"
event is inserted into the working memory.

rule "DelayTest" when $n : Number() from accumulate( $f : Foo() over
window:time(10s) count($f) ) then // bla end

The timer attribute seems to almost support what I'm looking for, i.e. it
allows for an initial-delay to be specified; but if the repeat interval is
omitted, it uses the initial delay as the repeat interval.

timer ( int:  ? )

In my case I would like to block the execution of the rule for an
"initial-delay" period, but after that time has elapsed the rule should
fire when every time a new "Foo" event is inserted into the working memory.
What is the recommended way to do this?

Thanks & Regards,

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


Re: [rules-users] CEP - @expires an event cause deadlock?

2011-02-13 Thread Paul R.
This sounds similar to an issue I experienced in 5.0.1 (
https://issues.jboss.org/browse/JBRULES-2375 ). What version of Drools are
you using?

2011/2/13 Wolfgang Laun 

> What do you mean by "...is stuck"?
>
> Please post the complete flow of application logic, from session creation,
> explaining how you insert and run the engine, and how you track retractions
> and the "stuck".
>
> -W
>
>
>
> On 13 February 2011 14:13, rodih  wrote:
>
>>
>> Hi,
>> I am new to CEP though I made a simple rule which which declares an event
>> as
>> expires after few milliseconds.
>> If events are inserted into a stream and at the same time events are
>> retracted from the stream due to expiration, the application is stuck -
>> Cant
>> insert any more events and no events are retracted.
>>
>> declare StockEventWrapper
>>   @role( event )
>>   @expires(10s)
>> end
>>
>> rule "Stock Event Buffer Rules"
>>dialect "java"
>>when
>> $stock : StockMotiveFactWrapper(timeAlerted == null)
>> $sew: StockEventWrapper(this.synonymContainedInTitle ==
>> true &&
>> $stock.stockId == this.stockId ,$stock.motiveTypeId == this.motiveTypeId)
>> over window:time(24h) from entry-point "STOCK_EVENTS"
>>then
>>System.out.println("Creating " + $stock.getStockId() + " "
>> +
>> $stock.getMotiveTypeId());
>>modify($stock){
>>setTimeAlerted(new Date());
>>}
>> end
>>
>> Any known issues? any ideas?
>>
>> Thanks,
>> Rod
>>
>>
>> --
>> View this message in context:
>> http://drools-java-rules-engine.46999.n3.nabble.com/CEP-expires-an-event-cause-deadlock-tp2485482p2485482.html
>> Sent from the Drools - User 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] Potential Deadlock using fireUntilHalt and signalEvent

2010-05-18 Thread Paul R.
This looks like an ago I logged a few months ago:
https://jira.jboss.org/jira/browse/JBRULES-2375

Cheers,

Paul

On Tue, May 18, 2010 at 6:09 PM, Barry Kaplan  wrote:

>
> Thanks for tracking that down. I've had to stop using fireUntilHalt due to
> deadlocks but did not get the chance to determine the problem.
>
> --
> View this message in context:
> http://drools-java-rules-engine.46999.n3.nabble.com/Potential-Deadlock-using-fireUntilHalt-and-signalEvent-tp826121p826897.html
> Sent from the Drools - User 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] Missing space when using DSL and Guvnor

2010-04-30 Thread Paul R.
Hi Jeff,

I logged a bug for this one a while back, here's the JIRA, patch details
included.

https://jira.jboss.org/jira/browse/GUVNOR-520

I would appreciate it if somebody could commit this for me :)

Cheers,

Paul

2010/4/30 Esteban Aliverti 

> It sounds like a bug. Can you double check it and create a jira issue
> please?
>
> best,
>
> 2010/4/29 Doyel,Jeff 
>
>>  I am setting up a very simple example using a DSL and Guvnor.  My DSL is
>> as follows:
>>
>> [when]Age is less than {age} years old=AgeFact(ageInYears < {age})
>>
>> When I attempt to create a new Business Rule using the Guvnor I can select
>> the above expression just fine and the sentence displays as expected.  I
>> then fill in the years with a numeric value (4) and validate.  Upon
>> validation I receive the following error.
>>
>> [Age Test Rule] [ERR 101] Line 4:2 no viable alternative at input 'Age' in
>> rule "Age Test Rule"
>>
>> I then view the source and it looks like this.
>>
>> rule "Age Test Rule"
>> dialect "mvel"
>> when
>> Age is less than 4years old
>> then
>> end
>>
>> I noticed that there is no space between the ‘4’ and the word ‘years’.
>> However, in my DSL sentence there is a space between {age} and years.
>> Another interesting thing, if I enter the number 4 followed by a space in
>> the Guvnor form then the rule validates correctly.  Is this a bug or is it
>> something I am doing wrong in my DSL?
>>
>> Thanks,
>> Jeff
>>
>>  --
>> CONFIDENTIALITY NOTICE This message and any included attachments are from
>> Cerner Corporation and are intended only for the addressee. The information
>> contained in this message is confidential and may constitute inside or
>> non-public information under international, federal, or state securities
>> laws. Unauthorized forwarding, printing, copying, distribution, or use of
>> such information is strictly prohibited and may be unlawful. If you are not
>> the addressee, please promptly delete this message and notify the sender of
>> the delivery error by e-mail or you may call Cerner's corporate offices in
>> Kansas City, Missouri, U.S.A at (+1) (816)221-1024.
>>
>> ___
>> rules-users mailing list
>> rules-users@lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>>
>
>
> --
> 
>
> Esteban Aliverti
>
> ___
> 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] Sliding Windows - Error

2010-03-30 Thread Paul R.
Hi Edson,

Many thanks for taking the time to respond. I think I should be able to
develop something using
the controlled clock approach outlined below.

Thanks again, and keep up the great work!

Best Regards,

Paul




2010/3/30 Edson Tirelli 

>
>Hi Paul,
>
>Unfortunately, the bottom line is that there is no magic. Time windows
> are always based on the concept of "current time" and to be able to join
> different streams of events Drools took the decision of having a
> session-scoped clock.
>
>The major problem of a fact timestamp be in the "past" is that it might
> miss the time window. But since we are taking decisions in near real time,
> the decisions for that window are already taken anyway, so not much that can
> be done if that happens.
>
>You asked for usual approaches. There are 2 general approaches that I
> know and the variations of them:
>
> 1. is to synchronize the incoming event streams. This is possible and
> common on playback systems, like telco rating/billing just to mention one
> example. This is not possible on live monitoring systems.
>
> 2. is to use a controlled clock based on the arriving of events. In this
> case, the clock is advanced based on the events arriving. Example: the clock
> could be advanced based on the most recent timestamp among all events that
> arrived, or based on the timestamp of a specific type of event that is
> handled like a heartbeat event.
>
>In the end, it obviously depends on the use case.
>
>Others might have additional suggestions, though.
>
>Edson
>
> 2010/3/27 Paul R. 
>
> Hi Edson.
>>
>> Many thanks for the response. Firing the rules before advancing the clock
>> fixes the problem. However,
>> I'm now looking for suggestions on how I can use time windows - when I
>> have events arriving from multiple
>> unsynchronized streams :)
>>
>> For example, I have two events StreamOne and StreamTwo, which have their
>> own timestamp properties,
>> both of these events are inserted into the a single session.
>>
>> StreamOne Data.
>>
>> timestamp = 2010-03-27 04:20:05, x = 0, y = 0
>> timestamp = 2010-03-27 04:20:10, x = 1, y = 0
>> timestamp = 2010-03-27 04:20:15, x = 1, y = 0
>> timestamp = 2010-03-27 04:20:20, x = 1, y = 0
>> timestamp = 2010-03-27 04:20:25, x = 0, y = 0
>>
>> StreamTwo Data.
>>
>> timestamp = 2010-03-27 04:20:10, x = 0, y = 0
>> timestamp = 2010-03-27 04:20:15, x = 1, y = 1
>> timestamp = 2010-03-27 04:20:20, x = 1, y = 1
>> timestamp = 2010-03-27 04:20:25, x = 0, y = 1
>> timestamp = 2010-03-27 04:20:30, x = 0, y = 1
>>
>> I would like to use simple rules like the following to capture particular
>> sequences of data.
>>
>> Number(intValue > 2) from accumulate
>> $f : StreamOne(x == 1)
>> over window:time ( 15s )
>>
>> from entry-point ChannelDataStream,
>> count($f))
>>
>>
>> Number(intValue > 2) from accumulate
>> $f : StreamOne(y == 1)
>> over window:time ( 15s )
>>
>> from entry-point ChannelDataStream,
>> count($f))
>>
>> Because the timestamps are in the past, and because of the fact that
>> multiple instances of the
>> same event type (different timestamps) may arrive at the same time, due to
>> network latency, etc.
>> This rules out the use of the real-time clock.
>>
>> I also can't see how I can reliably use the pseudo-clock because of the
>> lack of synchronization
>> of the timestamps between the two streams?
>>
>> Any suggestions greatly appreciated!
>>
>> Thanks and Regards,
>>
>> Paul
>>
>>
>>
>>
>>
>>
>>
>>
>> 2010/3/26 Edson Tirelli 
>>
>>
>>>Did you tried firing the rules before advancing the time clock?
>>>
>>>This is a very tricky situation because you are working with the edge
>>> limits of the time window. Events are expired from the time window when the
>>> clock advances. You are inserting events every 5 seconds. So, lets say you
>>> insert events on T0, T5, T10, T15, T20, T25... at this point in time the
>>> rule activates, but before it fires, you advance the clock to T30, when T0
>>> is expired from the window, making the condition intValue > 5 false and
>>> deactivating the rule.
>>>
>>> []s
>>> Edson
>>>
>>> 2010/3/25 Paul R. 
>>>
>>>>  Hi,
>>>>
>>>> I'm

[rules-users] Guvnor 5.0 DSL Validation bug (Internet Explorer only)

2010-03-30 Thread Paul R.
Guided Rule validation fails in Guvnor (Internet Explorer only), when Guided
rule contains DSL components.
It looks as though the LHS of the DSL isn't being substituted with the RHS
when validating.

I can't find a JIRA for this, does anybody know whether it's fixed in 5.1
M1?

Thanks and Regards,

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


Re: [rules-users] Sliding Windows - Error

2010-03-26 Thread Paul R.
Hi Edson.

Many thanks for the response. Firing the rules before advancing the clock
fixes the problem. However,
I'm now looking for suggestions on how I can use time windows - when I have
events arriving from multiple
unsynchronized streams :)

For example, I have two events StreamOne and StreamTwo, which have their own
timestamp properties,
both of these events are inserted into the a single session.

StreamOne Data.

timestamp = 2010-03-27 04:20:05, x = 0, y = 0
timestamp = 2010-03-27 04:20:10, x = 1, y = 0
timestamp = 2010-03-27 04:20:15, x = 1, y = 0
timestamp = 2010-03-27 04:20:20, x = 1, y = 0
timestamp = 2010-03-27 04:20:25, x = 0, y = 0

StreamTwo Data.

timestamp = 2010-03-27 04:20:10, x = 0, y = 0
timestamp = 2010-03-27 04:20:15, x = 1, y = 1
timestamp = 2010-03-27 04:20:20, x = 1, y = 1
timestamp = 2010-03-27 04:20:25, x = 0, y = 1
timestamp = 2010-03-27 04:20:30, x = 0, y = 1

I would like to use simple rules like the following to capture particular
sequences of data.

Number(intValue > 2) from accumulate
$f : StreamOne(x == 1)
over window:time ( 15s )
from entry-point ChannelDataStream,
count($f))


Number(intValue > 2) from accumulate
$f : StreamOne(y == 1)
over window:time ( 15s )
from entry-point ChannelDataStream,
count($f))

Because the timestamps are in the past, and because of the fact that
multiple instances of the
same event type (different timestamps) may arrive at the same time, due to
network latency, etc.
This rules out the use of the real-time clock.

I also can't see how I can reliably use the pseudo-clock because of the lack
of synchronization
of the timestamps between the two streams?

Any suggestions greatly appreciated!

Thanks and Regards,

Paul








2010/3/26 Edson Tirelli 

>
>Did you tried firing the rules before advancing the time clock?
>
>This is a very tricky situation because you are working with the edge
> limits of the time window. Events are expired from the time window when the
> clock advances. You are inserting events every 5 seconds. So, lets say you
> insert events on T0, T5, T10, T15, T20, T25... at this point in time the
> rule activates, but before it fires, you advance the clock to T30, when T0
> is expired from the window, making the condition intValue > 5 false and
> deactivating the rule.
>
> []s
> Edson
>
> 2010/3/25 Paul R. 
>
>>  Hi,
>>
>> I'm using an accumulate on a sliding window to count the number of events,
>> which occur in a 30 second window;
>> the events are inserted every 5 seconds - so with a 30 second window, I
>> would expect 6 events to occur.
>>
>> The rule below never fires, though from the log output, it looks as though
>> the condition has matched successfully?
>>
>> declare Foo
>> @role ( event )
>> @expires ( 60s )
>> @timestamp ( date )
>> end
>>
>> rule "Count Foo"
>> when
>> c : Number(intValue > 5) from accumulate
>> $f : Foo()
>> over window:time ( 30s )
>> from entry-point ChannelDataStream,
>> count($f))
>> then
>> System.out.println("Count [30s] = " + c);
>> end
>>
>> OBJECT ASSERTED value:com.test.droolstest$...@c52200 factId: 1
>> OBJECT ASSERTED value:com.test.droolstest$...@128edf2 factId: 3
>> OBJECT ASSERTED value:com.test.droolstest$...@1dddba factId: 4
>> OBJECT ASSERTED value:com.test.droolstest$...@c7e8a7 factId: 5
>> OBJECT ASSERTED value:com.test.droolstest$...@7b4703 factId: 6
>> ACTIVATION CREATED rule:Count Foo activationId:Count Foo [2, 0]
>> declarations: c=6(2)
>> OBJECT ASSERTED value:com.test.droolstest$...@1732ed2 factId: 7
>> ACTIVATION CANCELLED rule:Count Foo activationId:Count Foo [2, 0]
>> declarations: c=6(2)
>> ACTIVATION CREATED rule:Count Foo activationId:Count Foo [2, 0]
>> declarations: c=6(2)
>> OBJECT ASSERTED value:com.test.droolstest$...@be76c7 factId: 8
>> ACTIVATION CANCELLED rule:Count Foo activationId:Count Foo [2, 0]
>> declarations: c=6(2)
>> ACTIVATION CREATED rule:Count Foo activationId:Count Foo [2, 0]
>> declarations: c=6(2)
>>
>>
>> Can anybody explain why this is happening? I've attached a test case,
>> which demonstrates the problem.
>>
>> Thanks in advance.
>>
>> - Paul
>>
>> ___
>> 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
>
>
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Sliding Windows - Error

2010-03-25 Thread Paul R.
Meant to say: using drools 5.0.1.

- Paul

On Fri, Mar 26, 2010 at 1:22 AM, Paul R.  wrote:

> Hi,
>
> I'm using an accumulate on a sliding window to count the number of events,
> which occur in a 30 second window;
> the events are inserted every 5 seconds - so with a 30 second window, I
> would expect 6 events to occur.
>
> The rule below never fires, though from the log output, it looks as though
> the condition has matched successfully?
>
> declare Foo
> @role ( event )
> @expires ( 60s )
> @timestamp ( date )
> end
>
> rule "Count Foo"
> when
> c : Number(intValue > 5) from accumulate
> $f : Foo()
> over window:time ( 30s )
> from entry-point ChannelDataStream,
> count($f))
> then
> System.out.println("Count [30s] = " + c);
> end
>
> OBJECT ASSERTED value:com.test.droolstest$...@c52200 factId: 1
> OBJECT ASSERTED value:com.test.droolstest$...@128edf2 factId: 3
> OBJECT ASSERTED value:com.test.droolstest$...@1dddba factId: 4
> OBJECT ASSERTED value:com.test.droolstest$...@c7e8a7 factId: 5
> OBJECT ASSERTED value:com.test.droolstest$...@7b4703 factId: 6
> ACTIVATION CREATED rule:Count Foo activationId:Count Foo [2, 0]
> declarations: c=6(2)
> OBJECT ASSERTED value:com.test.droolstest$...@1732ed2 factId: 7
> ACTIVATION CANCELLED rule:Count Foo activationId:Count Foo [2, 0]
> declarations: c=6(2)
> ACTIVATION CREATED rule:Count Foo activationId:Count Foo [2, 0]
> declarations: c=6(2)
> OBJECT ASSERTED value:com.test.droolstest$...@be76c7 factId: 8
> ACTIVATION CANCELLED rule:Count Foo activationId:Count Foo [2, 0]
> declarations: c=6(2)
> ACTIVATION CREATED rule:Count Foo activationId:Count Foo [2, 0]
> declarations: c=6(2)
>
>
> Can anybody explain why this is happening? I've attached a test case, which
> demonstrates the problem.
>
> Thanks in advance.
>
> - Paul
>
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] Sliding Windows - Error

2010-03-25 Thread Paul R.
Hi,

I'm using an accumulate on a sliding window to count the number of events,
which occur in a 30 second window;
the events are inserted every 5 seconds - so with a 30 second window, I
would expect 6 events to occur.

The rule below never fires, though from the log output, it looks as though
the condition has matched successfully?

declare Foo
@role ( event )
@expires ( 60s )
@timestamp ( date )
end

rule "Count Foo"
when
c : Number(intValue > 5) from accumulate
$f : Foo()
over window:time ( 30s )
from entry-point ChannelDataStream,
count($f))
then
System.out.println("Count [30s] = " + c);
end

OBJECT ASSERTED value:com.test.droolstest$...@c52200 factId: 1
OBJECT ASSERTED value:com.test.droolstest$...@128edf2 factId: 3
OBJECT ASSERTED value:com.test.droolstest$...@1dddba factId: 4
OBJECT ASSERTED value:com.test.droolstest$...@c7e8a7 factId: 5
OBJECT ASSERTED value:com.test.droolstest$...@7b4703 factId: 6
ACTIVATION CREATED rule:Count Foo activationId:Count Foo [2, 0]
declarations: c=6(2)
OBJECT ASSERTED value:com.test.droolstest$...@1732ed2 factId: 7
ACTIVATION CANCELLED rule:Count Foo activationId:Count Foo [2, 0]
declarations: c=6(2)
ACTIVATION CREATED rule:Count Foo activationId:Count Foo [2, 0]
declarations: c=6(2)
OBJECT ASSERTED value:com.test.droolstest$...@be76c7 factId: 8
ACTIVATION CANCELLED rule:Count Foo activationId:Count Foo [2, 0]
declarations: c=6(2)
ACTIVATION CREATED rule:Count Foo activationId:Count Foo [2, 0]
declarations: c=6(2)


Can anybody explain why this is happening? I've attached a test case, which
demonstrates the problem.

Thanks in advance.

- Paul


DroolsTest.java
Description: Binary data
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Accumulate + Temporal Operators

2010-01-20 Thread Paul R.
Hi Greg,

Many thanks for the response. Works great!

Cheers,

Paul

On Mon, Jan 18, 2010 at 6:24 AM, Greg Barton  wrote:

> Yeah, you'll have to reinsert events into the stream, or another stream.
>  Probably the latter would be better.
>
> rule "DetectedFooAverageOver1"
> when
>   $f : Double(doubleValue > 1.0) from accumulate( Event($v : value, name ==
> "Foo") over window:time ( 10s ) from entry-point EntryPoint, average($v))
> then
>  entryPoints["DetectedStuff"].insert(new ComplexEvent("FooAvg", $f));
> end
>
> Then a similar rule for the Bar average, and a rule to test the coincidence
> of the complex events:
>
> rule "ComplexAvgBarPrettySoonAfterComplexAvgFoo"
> when
>  $foo : ComplexEvent(name == "FooAvg") from entry-point DetectedStuff
>  $bar : ComplexEvent(name == "BarAvg", this after[0s,1s] $foo) from
> entry-point DetectedStuff
> then
>  System.out.println("Uf, dah!");
> end
>
> And more fun can be had with this event aggregation idea.
>
> --- On Sun, 1/17/10, Paul R.  wrote:
>
> > From: Paul R. 
> > Subject: Re: [rules-users] Accumulate + Temporal Operators
> > To: "Rules Users List" 
> > Date: Sunday, January 17, 2010, 12:29 PM
> > I've declared an @expires of 30s for
> > both events. However, my problem is that within a 30 second
> > window it doesn't seem possible to ascertain whether
> > both of the events occur simultaneously. I could change the
> > @expires to 10 seconds for the above rule, which would make
> > it work. However, I would like to be to perform more
> > complicated matches, e.g. matching sequences of events which
> > occur after another.
> >
> >
> > $f : Double(doubleValue > 1.0) from
> > accumulate( Event($v : value, name == "Foo") over
> > window:time ( 10s )
> >
> > from entry-point EntryPoint,
> > average($v))
> >
> > // following event must start immediately
> > _after_ the above.
> >
> > $b : Double(doubleValue < 1.0) from
> > accumulate( Event($v : value, name == "Bar") over
> > window:time ( 20s )
> >
> > from entry-point EntryPoint,
> > average($v))
> >
> > Any suggestions how I can achieve this kind of
> > functionality?
> >
> > Many Thanks,
> >
> > Paul
> >
> >
> > On Sun, Jan 17, 2010 at 4:19 AM,
> > Greg Barton 
> > wrote:
> >
> > Do your Foo and Bar events declare
> > an @expires value?  If their expiration is less than 10
> > seconds then the rule below won't work properly. (And by
> > default an event's expiration is 0, which makes the rule
> > below go wacky if @expires hasn't been declared...)  If
> > the @expires is 10s or greater for both events it should
> > work.
> >
> >
> >
> >
> > --- On Thu, 1/14/10, Paul R. 
> > wrote:
> >
> >
> >
> > > From: Paul R. 
> >
> > > Subject: [rules-users] Accumulate + Temporal
> > Operators
> >
> > > To: rules-users@lists.jboss.org
> >
> > > Date: Thursday, January 14, 2010, 1:56 PM
> >
> > > Hi,
> >
> > >
> >
> > > I'm using accumulate with sliding windows to
> > verify
> >
> > > that certain event conditions are present for a
> > specified
> >
> > > period of time, which works fine, however
> >
> > > I need to verify that both conditions are present at
> > the
> >
> > > same time, i.e Foo.value > 1 for 10 seconds and
> > Bar.value
> >
> > > < 1 for 10 seconds. There doesn't
> >
> > >
> >
> > > appear to be an obvious way to use the temporal
> > operators
> >
> > > in this situation. Can anybody offer any suggestions?
> >
> > >
> >
> > > rule test no-loop true
> >
> > > when
> >
> > > $f : Double(doubleValue > 1.0) from
> >
> > > accumulate( Foo($v : value) over window:time ( 10s )
> >
> > >
> >
> > > from entry-point EntryPoint,
> >
> > > min($v))
> >
> > > $b : Double(doubleValue < 1.0) from
> >
> > > accumulate( Bar($v : value) over window:time ( 10s )
> >
> > > from entry-point EntryPoint,
> >
> > > max($v))
> >
> > > then
&

Re: [rules-users] Accumulate + Temporal Operators

2010-01-17 Thread Paul R.
I've declared an @expires of 30s for both events. However, my problem is
that within a 30 second window it doesn't seem possible to ascertain whether
both of the events occur simultaneously. I could change the @expires to 10
seconds for the above rule, which would make it work. However, I would like
to be to perform more complicated matches, e.g. matching sequences of events
which occur after another.

$f : Double(doubleValue > 1.0) from accumulate( Event($v : value,
name == "Foo") over window:time ( 10s )
from entry-point EntryPoint, average($v))

// following event must start immediately _after_ the above.

$b : Double(doubleValue < 1.0) from accumulate( Event($v : value,
name == "Bar") over window:time ( 20s )
from entry-point EntryPoint, average($v))

Any suggestions how I can achieve this kind of functionality?

Many Thanks,

Paul


On Sun, Jan 17, 2010 at 4:19 AM, Greg Barton  wrote:

> Do your Foo and Bar events declare an @expires value?  If their expiration
> is less than 10 seconds then the rule below won't work properly. (And by
> default an event's expiration is 0, which makes the rule below go wacky if
> @expires hasn't been declared...)  If the @expires is 10s or greater for
> both events it should work.
>
> --- On Thu, 1/14/10, Paul R.  wrote:
>
> > From: Paul R. 
> > Subject: [rules-users] Accumulate + Temporal Operators
> > To: rules-users@lists.jboss.org
> > Date: Thursday, January 14, 2010, 1:56 PM
> > Hi,
> >
> > I'm using accumulate with sliding windows to verify
> > that certain event conditions are present for a specified
> > period of time, which works fine, however
> > I need to verify that both conditions are present at the
> > same time, i.e Foo.value > 1 for 10 seconds and Bar.value
> > < 1 for 10 seconds. There doesn't
> >
> > appear to be an obvious way to use the temporal operators
> > in this situation. Can anybody offer any suggestions?
> >
> > rule test no-loop true
> > when
> > $f : Double(doubleValue > 1.0) from
> > accumulate( Foo($v : value) over window:time ( 10s )
> >
> > from entry-point EntryPoint,
> > min($v))
> > $b : Double(doubleValue < 1.0) from
> > accumulate( Bar($v : value) over window:time ( 10s )
> > from entry-point EntryPoint,
> > max($v))
> > then
> >
> > // ...
> > end
> >
> > Any help greatly appreciated.
> >
> > Thanks,
> >
> > Paul
> >
> >
> > -Inline Attachment Follows-
> >
> > ___
> > 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


[rules-users] Accumulate + Temporal Operators

2010-01-14 Thread Paul R.
Hi,

I'm using accumulate with sliding windows to verify that certain event
conditions are present for a specified period of time, which works fine,
however
I need to verify that both conditions are present at the same time, i.e
Foo.value > 1 for 10 seconds and Bar.value < 1 for 10 seconds. There doesn't
appear to be an obvious way to use the temporal operators in this situation.
Can anybody offer any suggestions?

rule test no-loop true
when
$f : Double(doubleValue > 1.0) from accumulate( Foo($v : value) over
window:time ( 10s )
from entry-point EntryPoint, min($v))
$b : Double(doubleValue < 1.0) from accumulate( Bar($v : value) over
window:time ( 10s )
from entry-point EntryPoint, max($v))
then
// ...
end

Any help greatly appreciated.

Thanks,

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


[rules-users] Drools Fusion deadlock?

2009-12-14 Thread Paul R.
Hi,

I'm having a problem in my project; inserting large quantities of facts into
a StatefulKnowledgeSession (stream mode) causes my code to hang after a few
minutes of activity. I've attached a simple test to demonstrate the problem;
when I run the attached code ~ 20 objects get inserted into the session, the
rule fires once and then hangs. No more facts get inserted and the rule
never fires again.

Is there anything obvious wrong with the attached code, or is it possible
that this is a bug in drools [drools-5.0.1]?

Thanks and regards,

Paul


Main.java
Description: Binary data
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Drools Guvnor and jboss single sign on

2009-12-10 Thread Paul R.
Did you also edit your drools-guvnor.war\WEB-INF\components.xml to point to
your authenticator?




2009/12/10 Sahid Khan (সাহিদ) 

> 2009/12/10 Paul R. :
> > It's very easy to create a custom authentication module for Seam. In my
> > organization, we've created a simple module which will check the session
> for
> > an existing user object. Just have to put it on your classpath and edit
> the
> > components.xml to use your class as its authenticator. Perhaps something
> > like this will work for you?
> >
>
> Thank you. However this is not working. I have created a custom
> authenticator as you said and put in WEB-INF/classes, but that is not
> getting invoked. I was just going through the Guvnor web.xml file, I
> don't see any security-constraints there. So that means Guvnor does
> not use standard JAAS security for authentication. Is that the reason,
> the custom authenticator is not getting invoked?
>
> Thanks,
> --
> S.
> Argue with idiots, and you become an idiot. - PG
> ___
> 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] Drools Guvnor and jboss single sign on

2009-12-09 Thread Paul R.
It's very easy to create a custom authentication module for Seam. In my
organization, we've created a simple module which will check the session for
an existing user object. Just have to put it on your classpath and edit the
components.xml to use your class as its authenticator. Perhaps something
like this will work for you?

Cheers,

Paul

import org.jboss.seam.security.Identity;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.contexts.Contexts;

@Name("customAuthenticator")
public class CustomAuthenticator {

public boolean authenticate() {

User userBean = (User) Contexts.getSessionContext()
.get("SESSIONID");

if (userBean == null || userBean.getUsername() == null) {
log.info( "No Session" );
return false;
} else {
log.info( "Setting username to " + userBean.getUsername() );
Identity.instance().getCredentials().setUsername(
userBean.getUsername() );
return true;
}
}
}



2009/12/9 Sahid Khan (সাহিদ) 

> Hello,
>
> I have couple of web applications other than Guvnor deployed in JBoss.
> I use jboss single sign on [1] for authentication. But guvnor does not
> seem to be working. I believe there are some issues with JBoss Seam
> and JBoss SSO. But is there any work around to integrate JBoss SSO
> with Guvnor? Please help.
>
> 1. http://www.jboss.org/community/wiki/JBossWebSingleSignOn
>
> Thanks in advance,
> --
> Sahid.
> Argue with idiots, and you become an idiot. - PG
> ___
> 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] CEP + prevent consequences from triggering multiple times?

2009-12-03 Thread Paul R.
Hi Greg,

Thanks for the response. Unfortunately your example doesn't appear to work,
the SpeedIndicator doesn't get retracted, causing the consequence to only
ever trigger once. However, I could add another rule to remove the
SpeedingIndicator - meaning I no longer have to use the nasty global "state"
object from my example.

Any other suggestions greatly appreciated.

Cheers,

Paul

On Thu, Dec 3, 2009 at 7:14 PM, Greg Barton  wrote:

> Have you tried truth maintenance? (i.e. insertLogical)
>
> rule "OverSpeedLimit" no-loop true
> when
> not SpeedingIndicator();
>$minSpeed : Double(doubleValue > 100) from accumulate(
> $speedingEvent : SpeedingEvent ($speed : speed)
>over window:time( 30s )
>from entry-point SpeedingStream,
>min($speed)
>);
> then
>insertLogical(new SpeedingIndicator());
> end
>
> Though I'm not sure this will work, because inserting the SpeedingIndicator
> negates the first condition, probably causing the SpeedingIndicator to be
> retracted automatically. :)  But it's worth a try just to see if no-loop
> would override that somehow.
>
> Apart from that, note that you can test the results of an accumulate in the
> returned value. (The "Double(doubleValue > 100)" part.)  YOu don't need the
> eval.
>
> Also, where is the "state" object coming from?  If it's a global, it's not
> a good idea to use them in the conditions of your rules.  Changes to them
> are not tracked by the rete.
>
> --- On Thu, 12/3/09, reverselogic  wrote:
>
> > From: reverselogic 
> > Subject: [rules-users] CEP + prevent consequences from triggering
> multiple times?
> > To: rules-users@lists.jboss.org
> > Date: Thursday, December 3, 2009, 12:41 PM
> >
> > Hi,
> >
> > I'm trying to write a rule in drools, which triggers once
> > some condition is
> > active for a specified time interval. For example, if a
> > vehicle is over a
> > speed limit (100 mph) for 30 seconds, I want to trigger an
> > action. However,
> > once this rule has fired, I don't want it to fire again
> > until the vehicle
> > has dropped below the speed limit (and gone over the limit
> > again). The only
> > way I've managed to model this is by defining two rules;
> > one for determining
> > when the vehicle is speeding and one for determining when
> > it is not speeding
> > and using a global object to track the state of the vehicle
> > (see rules
> > below).
> >
> > rule "OverSpeedLimit" no-loop true
> > when
> > $minSpeed : Double() from accumulate(
> > $speedingEvent :
> > SpeedingEvent ($speed : speed)
> >
> > over window:time( 30s )
> >
> > from entry-point SpeedingStream,
> > min($speed)
> > );
> >
> > eval ($minSpeed > 100.0 &&
> > !state.speeding)
> > then
> > state.speeding = true
> > end
> >
> > rule "!OverSpeedLimit" no-loop true
> > when
> > $speedingEvent : SpeedingEvent()
> > from entry-point
> > SpeedingStream
> > eval ($speedingEvent.speed <= 100.0)
> > then
> > state.speeding = false
> > end
> >
> > My questions is: Is there a better way to model the above
> > behaviour,
> > preferably as a single rule? The reason I ask is because I
> > believe it would
> > be too complicated for my users to define rules like this.
> > Ideally, I would
> > like to be able to create a DSL such as: "when Speed is
> > above X for Y
> > seconds then ..."
> >
> > Any help greatly appreciated.
> >
> > Thanks,
> >
> > Paul
> >
> >
> >
> >
> > --
> > View this message in context:
> http://n3.nabble.com/CEP-prevent-consequences-from-triggering-multiple-times-tp67424p67424.html
> > Sent from the Drools - User 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