簡體   English   中英

SWF:如何從子工作流程中發信號通知父工作流程?

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

我試圖發信號通知我的父級工作流以更新其狀態變量。 父工作流程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(...);
}

但是,這會在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},...

當我初始化不帶參數的ClientExternalFactory

private ParentWorkflowClientExternalFactory clientExternalFactory = new ParentWorkflowClientExternalFactoryImpl();

引發的異常是: 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這樣做:

private MyWorkflowState state;

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

有什么建議嗎?

從工作流界面生成的客戶端有兩種。 內部和外部的。 內部代碼應在工作流代碼中使用,外部代碼應在工作流外部使用(例如,從Web服務器使用)。 您正在嘗試在不支持的工作流程中使用外部客戶端。 使用內部客戶端(使用ParentWorkflowClientFactory創建)。 有關更多信息,請參見Flow Development Guide

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM