我要求工作流应该从哪里开始执行,但它应该等待下一个后续事件来执行。基于服务从客户端接收的API调用生成事件。事件语义基于状态机。请告诉我如何在java中实现它。请提供任何示例代码供参考。
答案 0 :(得分:0)
如果您使用的是AWS Flow Framework,则外部事件应使用Signal API来通知工作流实例。在工作流程内部,它变成了一个处理程序方法,如:
@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描述了如何编写工作流界面。
http://docs.aws.amazon.com/amazonswf/latest/awsflowguide/workflowimpl.html介绍了如何实施工作流程。
http://docs.aws.amazon.com/amazonswf/latest/awsflowguide/clients.html描述了如何使用外部客户端发送信号。