简体   繁体   English

AWS SWF - 工作流传递活动结果以及驱动工作流的信号

[英]AWS SWF - Workflow passing activity results with signals driving the workflow

I have the requirement to use AWS Simple Workflow (SWF) for an orchestration type of system design.我需要将 AWS 简单工作流 (SWF) 用于编排类型的系统设计。 There is parent application that is start this child workflow then signal the workflow to work on activities.有父应用程序启动此子工作流,然后向工作流发出信号以处理活动。 I have a workflow that starts up and waits for signals to happen before it can start doing activity work.我有一个工作流程启动并等待信号发生,然后才能开始进行活动工作。 Once one activity is done then it will report back to by closing out the activity on the parent workflow.一旦完成一项活动,它将通过关闭父工作流上的活动来报告。

How do I wait for the signal and also use the results from another activity that was invoked by a signal?如何等待信号并使用信号调用的另一个活动的结果?

Do I need to look into the execution history for the result of an activity and not rely on doing this work in the decide?我是否需要查看活动结果的执行历史记录,而不是依赖于在决定中执行此工作?

Thanks for the help谢谢您的帮助

Code Example:代码示例:

@SuppressWarnings("unused")
@Slf4j
public class ChildWorkflowImpl implements ChildWorkflow {
    private final Settable<Message> firstStepReceived = new Settable<>();
    private final Settable<Message> secondStepReceived = new Settable<>();


    @Autowired
    private FirstActivityClient firstActivityClient;

    @Autowired
    private SecondActivityClient secondActivityClient;


    @Autowired
    private AmazonSimpleWorkflow amazonSimpleWorkflow;

    @Override
    public void startWorkflow(SubsystemMessage subsystemMessage) {

        //wait for signal to start
        new Task(firstStepReceived) {
            @Override
            protected void doExecute() throws Throwable {
                //Initiate Activity

                startStage(firstStepReceived.get(););
            }
        };

        //wait for second signal but pass in data from first activity
        new Task(secondStepReceived) {
            @Override
            protected void doExecute() throws Throwable {

            }
        };


    }

    public void firstStep(Message message) {
        Promise<FirstActivityResponse> firstActivity = firstActivityClient.execute();

        //wait for signal for disable
        new Task(firstActivity) {
            public void doExecute() {
                //report back status for stage by closing parent activity
            }
        };
    }

    public void secondStep(FirstActivityResponse response) {
        Promise<SecondActivityResponse> secondActivityResponse = secondActivityClient.execute(response);

        new Task(secondActivityResponse) {
            public void doExecute() {
                //report back status for stage
            }
        };

    }
}

You add a signal method to the workflow interface and use Settable to notify the other part of the workflow code about the signal.您将信号方法添加到工作流接口并使用 Settable 通知工作流代码的另一部分有关信号。 See Settable documentation from this documentation page.请参阅此文档页面中的可设置文档。

BTW.顺便提一句。 I recommend looking at temporal.io which is a greatly improved version of SWF which supports synchronous programming without all these pesky tasks.我建议查看temporal.io ,它是 SWF 的一个大大改进的版本,它支持同步编程而没有所有这些讨厌的任务。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM