1

I have a requirement where I need to invoke an activity in SWF after x minutes. For this I am planning to start a timer in SWF(for x minutes) and invoke the activity when timer fires. Can I get a pointer on how to start timer in SWF? Another requirement is I might some time have to cancel the timer as well, in cases where I needn't wait for complete duration. Is there anything for canceling a started timer in SWF? Can someone point me to the required APIs?

Thanks!

nishant
  • 59
  • 1
  • 6

1 Answers1

1

You cannot cancel a timer in SWF. However, I think you can configure your workflow worker to ignore the timer altogether if a certain condition is met. You can design the workflow such that it carries on its activities based on which of two promises gets fulfilled first, using the OrPromise:

http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/simpleworkflow/flow/core/OrPromise.html

One promise could be your timer, the other could be your condition to carry on. Let me know if this helps.

Ana Todor
  • 781
  • 1
  • 6
  • 15
  • 1
    Not sure if this was added at a later date, but it _is_ possible to cancel a timer in SWF: http://docs.aws.amazon.com/amazonswf/latest/developerguide/swf-dg-signals.html (specifically "If a signal has arrived, cancel the timer using a CancelTimer decision and process the signal"). Also see http://docs.aws.amazon.com/amazonswf/latest/apireference/API_Decision.html (specifically "CancelTimer: cancels a previously started timer and records a TimerCanceled event in the history"). – user183037 Oct 21 '16 at 08:45