Apama 10.3 | Apama Documentation | Developing Apama Applications | Developing Apama Applications in EPL | Defining Event Listeners | Defining event listeners with temporal constraints | Triggering event listeners at specific times
Triggering event listeners at specific times
The at temporal operator lets you express temporal activity with regards to absolute time. The at operator allows triggering of a timer:
*at a specific time, for example, 12:30pm on the 5th April
*repeatedly with regards to the calendar when used in conjunction with the all operator, across seconds, minutes, hours, days of the week, days of the month, and months, for example, on every hour, or on the first day of the month, or every 10 minutes past the hour and every 40 minutes past the hour
The syntax of the at operator is as follows:
at(minutes, hours, days_of_month, months, days_of_week [ ,seconds])
where the last operand, seconds, is optional.
Valid values for each operand are as follows:
0 to 59, indicating minutes past the hour.
0 to 23, indicating the hours of the day.
1 to 31, indicating days of the month. For some months only 1 to 28, 1 to 29 or 1 to 30 are valid ranges.
1 to 12, indicating months of the year, with 1 corresponding to January
0 to 6, indicating days of the week, where 0 corresponds to Sunday.
0 to 59, indicating seconds past the minute.
The at operator can be embedded within an event expression in a manner similar to the wait operator. If used outside the scope of an all operator it will trigger only once, at the next valid time as expressed within its elements. In conjunction with an all operator, it will trigger at every valid time.
The wildcard symbol (*) can be specified to indicate that all values are valid, for example:
on at(5, *, *, *, *) success();
would trigger at the next “five minutes past the hour”, while
on all at(5, *, *, *, *) success();
would trigger at five minutes past each hour (that is, every day, every month).
on all at(5, 9, *, *, *) success();
would trigger at 9:05am every day. However,
on all at(5, 9, *, *, 1) success();
would trigger at 9:05am only on Mondays, and never on any other week day. This is because the effect of the wildcard operator is different when applied to the days_of_week and the days_of_month operands. This is due to the fact that both specify the same entity. The rule is therefore as follows:
*As long as both elements are set to wildcard, then each day is valid.
*If either of the days_of_week or the days_of_month operand is not a wildcard, then only the days that match that element will be valid. The wildcard in the other element is effectively ignored.
*If both the days_of_week and the days_of_month operands are not wildcards, then the days valid will be the days which match either. That is, the two criteria are ‘or' 'ed, not ‘and' 'ed.
A range operator (:) can be used with each element to define a range of valid values. For example:
on all at(5:15, *, *, *, *) success();
would trigger every minute from 5 minutes past the hour till 15 minutes past the hour.
A divisor operator (/integer, x) can be used to specify that every x'th value is valid. Therefore
on all at(*/10, *, *, *, *) success();
would trigger every ten minutes, that is, at 0, 10, 20, 30, 40 and 50 minutes past every hour.
If you wish to specify a combination of the above operators you must enclose the element in square braces ([ ]), and separate the value definitions with a comma (,). For example
on all at([*/10,30:35,22], *, *, *, *) success();
indicates the following values for minutes to trigger on; 0,10, 20, 30, 40 and 50, from 30 to 35, and specifically the value 22.
A further example,
on all at(*/30,9:17,[*/2,1],*,*) success();
would trigger every 30 minutes from 9am to 5pm on even numbered days of the month as well as specifically the first day of the month.

Copyright © 2013-2018 | Software AG, Darmstadt, Germany and/or Software AG USA, Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors.