[rules-users] Writting a fusion query with specific time intervals

Wolfgang Laun wolfgang.laun at gmail.com
Tue Jul 12 07:47:26 EDT 2011


On 11 July 2011 18:45, Amila Suriarachchi <amilaSuriarachchi at gmail.com>wrote:

> yes it is a fixed window.
>
> How to use the 'cron timers' in a rule file I am bit new to fusion. so if
> you show me an article or a code segment regarding this that would be fine.
>

rule OneMinutesPastEveryFullHour
timer( cron: * 1 * * * ? )
when
then
      // get current hour, access counter,...
end

You might use additional values (e.g., 9-17 for the "hour" field, i.e., '*'
after '1').

See
   man -s 5 crontab
for more info. Notice that Drools timer/crontab has an additional leading
field for seconds.

>
> And also how to run a rule just after an event appears?
>

This assumes that you do not modify Event here or elsewhere. Using a global
array with 24 integers initialized to 0 you can do:

rule newEvent
when
      $e: Event()
then
     // Count new event
     globalCounter[hourOf( $e.getTimestamp() )]++;
end


>
> thanks,
> Amila.
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/Writting-a-fusion-query-with-specific-time-intervals-tp3151010p3159730.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20110712/c293a29b/attachment.html 


More information about the rules-users mailing list