I am using the JAVA SDK. I have a workflow like the following
Send email
Sleep for 5 days
Send email
Sleep for 5 days
Create salesforce case
Sleep for 2 days
Post in slack
Create a JIRA ticket
Based on certain external events in the system, I want to skip all steps and directly jump to Step 7. The workflow could be in any step when the signal is received by the workflow. I.e the workflow could be sleeping as well. How can I achieve this
1.I will have to add the if statement after every activity execution in this function.
2. And what happens if a signal is received when the workflow has executed one of the sleep steps for X days. If the external signal arrives when the workflow is sleeping, how can I cancel the sleep and jump all the required remaining steps and move to postInSlack, createJIRA. Is there a way to interrupt the sleep when the external signal arrives ?
Ah, thanks for the pointer to use Workflow.await and not sleep.
By any chance have you seen DSLs constructed generically to express this pattern. i.e A workflow defined as a sequence of steps and the ability to skip certain steps and continue execution from a step in response to a signal. Trying to see how this could be generalized in a DSL so that developers can just express this in DSL rather than building the same logic multiple times. This seems more like GOTO pattern