quartz-schedulercronexpressionsiddhiwso2-cep

Combine two Cronexpressions


I have the next CronExpression in Siddhi (wso2 DAS):

define trigger periodicalTriggerStream at '0 0/15 * * * ?';

This expression is runing without problems, run every 15 mins

15, 30, 45 ....

I need that my trigger run when I start SIDDHI.

0, 15, 30, 45

Is posible combine two expressions?:

define trigger periodicalTriggerStream at '0 0/15 * * * ?';

define trigger periodicalTriggerStream at 'start'; 

Solution

  • Event triggers will generate events on an event stream with name same as the event trigger, having only one attribute with name "triggered_time" and type long. Basically, once the trigger emits an event, it behaves similar to an event stream. Therefore, we can put both cron events, start events in to a event stream and use it.

    define trigger cronTriggerStream at '0 0/15 * * * ?';
    
    define trigger startTriggerStream at 'start'; 
    
    from cronTriggerStream
    insert into periodicalTriggerStream;
    
    from startTriggerStream
    insert into periodicalTriggerStream;