I have requirement where workflow should start execution but it should wait for next subsequent events to do the execution. Events are generated based of API calls that the service receives from client. The events semantics is based on a state machine. Please let me know how this can be implemented in java. Please provide any sample code for reference.
Asked
Active
Viewed 183 times
1 Answers
0
If you are using AWS Flow Framework an external event should use Signal API to notify a workflow instance. Inside a workflow it becomes a handler method like:
@Workflow
@WorkflowRegistrationOptions(
defaultExecutionStartToCloseTimeoutSeconds = 60,
defaultTaskStartToCloseTimeoutSeconds = 10)
public interface MyWorkflow
{
@Execute(version = "1.0")
void startMyWF();
@Signal
void signal1();
}
public class MyWFImpl implements MyWorkflow
{
MyActivitiesClient client = new MyActivitiesClientImpl();
// Used to block the workflow until a signal is received.
Settable<Void> signal1Called = new Settable<Void>();
@Override
public void startMyWF(){
Promise<Integer> result = client.activity1();
// Continues when both result and signal1 are ready.
client.activity2(result, signal1);
}
@Override
public void signal1() {
//Process signal
signal1.set(null);
}
}
http://docs.aws.amazon.com/amazonswf/latest/awsflowguide/features.workflow.html describes how to write a workflow interface.
http://docs.aws.amazon.com/amazonswf/latest/awsflowguide/workflowimpl.html describes how to implement workflows.
http://docs.aws.amazon.com/amazonswf/latest/awsflowguide/clients.html describes how to send signals using external client.

Maxim Fateev
- 6,458
- 3
- 20
- 35
-
won't I need to implement all the state machine logic using Deciders. like the if else scenarios given in [AWS link] (http://docs.aws.amazon.com/amazonswf/latest/developerguide/swf-dg-dev-deciders.html) ? – Ravi Kanth Dec 04 '17 at 05:08
-
or to be precise how can have this logic implemented in Java? IF lastEvent = "StartWorkflowInstance" addToDecisions ScheduleVerifyOrderActivity ELSIF lastEvent = "CompleteVerifyOrderActivity" addToDecisions ScheduleChargeCreditCardActivity ELSIF lastEvent = "CompleteChargeCreditCardActivity" addToDecisions ScheduleCompleteShipOrderActivity ELSIF lastEvent = "CompleteShipOrderActivity" addToDecisions ScheduleRecordOrderCompletion ELSIF lastEvent = "CompleteRecordOrderCompletion" addToDecisions CloseWorkflow ENDIF – Ravi Kanth Dec 04 '17 at 05:18
-
Please, don't do it. Just use the Flow Framework. It takes care of all low level details which are pretty cumbersome. See http://docs.aws.amazon.com/amazonswf/latest/awsflowguide/welcome.html – Maxim Fateev Dec 05 '17 at 04:33
-
i went through documentation but I'm confused as to how to implement my use case. Can you provide your email id. I'll tell you the exact use case. ravikanth828@gmail.com is my email id – Ravi Kanth Dec 06 '17 at 13:21