简体   繁体   English

SWF:如何从子工作流程中发信号通知父工作流程?

[英]SWF: How can I signal the parent workflow from the child workflow?

I'm trying to signal my parent workflow to update its state variable. 我试图发信号通知我的父级工作流以更新其状态变量。 The parent workflow id is passed to the child workflow's execute method. 父工作流程ID传递给子工作流程的execute方法。

@Autowired
private AmazonSimpleWorkflowClient swfClient;
@Autowired
private String swfDomain;

private ParentWorkflowClientExternalFactory clientExternalFactory = new ParentWorkflowClientExternalFactoryImpl(swfClient, swfDomain);

@Override
public Promise<String> childActivityMethod(String parentWorkflowId) {
    ParentWorkflowClientExternal clientExternal = clientExternalFactory.getClient(parentWorkflowId);
    clientExternal.updateState(...);
}

However, this throws a NullPointerException in SWF code (AmazonSimpleWorkflow is null): 但是,这会在SWF代码中引发NullPointerException (AmazonSimpleWorkflow为null):

["java.lang.NullPointerException",{"cause":null,"stackTrace":[{"methodName":"signalWorkflowExecution","fileName":"GenericWorkflowClientExternalImpl.java","lineNumber":87,"className":"com.amazonaws.services.simpleworkflow.flow.worker.GenericWorkflowClientExternalImpl","nativeMethod":false},{"methodName":"signalWorkflowExecution","fileName":"DynamicWorkflowClientExternalImpl.java","lineNumber":167,"className":"com.amazonaws.services.simpleworkflow.flow.DynamicWorkflowClientExternalImpl","nativeMethod":false},...

When I initialize the ClientExternalFactory without the parameters: 当我初始化不带参数的ClientExternalFactory

private ParentWorkflowClientExternalFactory clientExternalFactory = new ParentWorkflowClientExternalFactoryImpl();

The exception thrown is: The required property genericClient is null. It could be caused by instantiating the factory through the default constructor instead of the one that takes service and domain arguments. 引发的异常是: The required property genericClient is null. It could be caused by instantiating the factory through the default constructor instead of the one that takes service and domain arguments. The required property genericClient is null. It could be caused by instantiating the factory through the default constructor instead of the one that takes service and domain arguments.

ParentWorkflow#updateState does this: ParentWorkflow#updateState这样做:

private MyWorkflowState state;

// This method has @Signal in the interface.
@Override
public void updateState(MyWorkflowState newState) {
    state = newState;
}

Any advice? 有什么建议吗?

There are two types of clients generated from the workflow interfaces. 从工作流界面生成的客户端有两种。 The internal and external ones. 内部和外部的。 Internal are expected to be used from within a workflow code and external ones to be used outside of a workflow (for example from a web server). 内部代码应在工作流代码中使用,外部代码应在工作流外部使用(例如,从Web服务器使用)。 You are trying to use an external client inside a workflow which is not supported. 您正在尝试在不支持的工作流程中使用外部客户端。 Use the internal client (created using ParentWorkflowClientFactory) instead. 使用内部客户端(使用ParentWorkflowClientFactory创建)。 See Flow Development Guide for more info. 有关更多信息,请参见Flow Development Guide

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

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