0

I would like to implement my own custom trigger. the main purpose of the trigger twice: on start date and end date (think of it as on/off switch, "on" state and start date and "off" state on end date).

What is best way to achieve that?

AbstractTrigger or implement ITrigger?

Implementing IScheduleBuilder is required?

Amr Ellafy
  • 730
  • 8
  • 26

2 Answers2

1

When you start to wonder whether to implement your own trigger there's possibly something going to the wrong direction. Quartz has a rich set of triggers that should cater for various scheduling needs which are based on interval/reoccurrence rules.

Not fully understanding your use case, I'd just schedule two triggers for start and stop actions. You could parametrize the triggers to supply the operation mode via job data map (TurnOn, TurnOff). You easily have start action to run on times like 8:35 am, every Monday, Wednesday and Saturday and corresponding stop trigger say the given dates on 10 pm.

Marko Lahma
  • 6,586
  • 25
  • 29
  • Think of it as a schedule for an alarm that should be active from 16:00 PM and 20:00 PM and it will run only once (not recurring). both Simple and Cron triggers are recurring. I manager to create such trigger by extending AbstactTrigger and implementing ISchedulerBuilder. It works. – Amr Ellafy Feb 26 '15 at 14:32
  • Simple trigger with repeat count of 1 is not recurring, so you can model non recurring triggers too. – Marko Lahma Feb 27 '15 at 08:51
  • Yes. But the purpose of this trigger is to run twice at two specific dates. Can this be achieved by the simple trigger? – Amr Ellafy Feb 28 '15 at 02:33
  • @AmrEllafy can you share your impmlementation? – lstanczyk Sep 30 '22 at 17:37
  • @lstanczyk sorry, that was so long ago, the code is gone. – Amr Ellafy Oct 03 '22 at 21:16
0

I created the custom trigger by extending AbstactTrigger and implementing ISchedulerBuilder specified to this trigger type.

Amr Ellafy
  • 730
  • 8
  • 26