我们正在创建一个包含多个活动的工作流程。其中一项活动是直接调用Lambda函数。 Lambda函数在不使用工作流的情况下正确执行(使用AWS Lambda控制台)。当使用SWF调用它时,函数不会被调度,也不会抛出任何错误。
Lambda函数的骨架如下。
public String handleRequest(String path, Context context) {
System.out.println("unknown status");
return "unknown status";
}
工作流程实施
public class WorkflowAImpl implements WorkflowA {
private ActivityOneClient processClient = new ActivityOneClientImpl();
private ActivityTwoClient filterClient = new ActivityTwoClientImpl();
@Override
public Promise<String> process(String BucketNameFromMain,
String Message) {
WorkflowStatistics statistics = new WorkflowStatistics();
DecisionContextProvider context = new DecisionContextProviderImpl();
DecisionContext decisionContext = context.getDecisionContext();
String workflowName = context.getDecisionContext().getWorkflowContext()
.getWorkflowExecution().getWorkflowId();
String workflowId = context.getDecisionContext().getWorkflowContext()
.getWorkflowExecution().getRunId();
BucketName = BucketNameFromMain;
Promise<String> FirstDone = FirstActivity();
Promise<String> SecondDone = translateMessageActivity(FirstDone,decisionContext);
Promise<String> ThirdDone = insertMessageActivity(SecondDone);
return ThirdDone;
}
@Asynchronous
public Promise<String> FirstActivity() {
Promise<String> FirstDone = processClient.ProcessMessage();
return FirstDone;
}
@Asynchronous
public Promise<String> insertMessageActivity(Promise<String> SecondDone) {
Promise<String> ThirdDone = filterClient.FilterMessage();
return ThirdDone;
}
@Asynchronous
public Promise<String> translateMessageActivity(Promise<String> FirstDone,DecisionContext decisionContext) {
LambdaFunctionClient lambdaClient =decisionContext.getLambdaFunctionClient();
Promise<String> SecondDone =lambdaClient.scheduleLambdaFunction("LambdaFunctionName",inputData);
return SecondDone;
}
}
正在执行第一项活动。之后,它不会安排lambda函数。请帮助
参考:http://docs.aws.amazon.com/amazonswf/latest/awsflowguide/lambda-task.html https://github.com/aws/aws-sdk-java/tree/master/src/samples/AwsFlowFramework/src/com/amazonaws/services/simpleworkflow/flow/examples/hellolambda