Triggers allow events to be periodically generated. Trigger definition can be used to define a trigger. A trigger also works like a stream with a predefined schema.
For some use cases the system should be able to periodically generate events based on a specified time interval to perform some periodic executions.
A trigger can be performed for a
'start' operation, for a given
<time interval>, or for a given
The syntax for a trigger definition is as follows.
CREATE TRIGGER <trigger name> at ('start'| every <time interval>| '<cron expression>');
Similar to streams, triggers can be used as inputs. They adhere to the following stream definition and produce the
triggered_time attribute of the
CREATE STREAM <trigger name> (triggered_time long);
The following types of triggeres are currently supported:
|An event is triggered when Stream is started.|
|An event is triggered periodically at the given time interval.|
|An event is triggered periodically based on the given cron expression. For configuration details, see quartz-scheduler.|
Triggering events regularly at specific time intervals
The following query triggers events every 5 minutes.
CREATE TRIGGER FiveMinTriggerStream at every 5 min;
Triggering events at a specific time on specified days
The following query triggers an event at 10.15 AM on every weekdays.
CREATE TRIGGER FiveMinTriggerStream at '0 15 10 ? * MON-FRI';