等待信号开始活动(亚马逊工作流程)

时间:2015-03-30 10:47:28

标签: java amazon-web-services workflow aws-sdk amazon-swf

我使用AWS提供的java流程框架构建了一个工作流程。我创建了4个活动。第一个活动等待信号开始。然后使用Promise<>同步执行所有活动。宾语。工作流实现代码如下 -

public class PaginationWorkflowImpl implements PaginationWorkflow 
{  
private ManualUploadClient operations0 = new ManualUploadClientImpl();
   private DownloadActivityClient operations1 = new DownloadActivityClientImpl();
   private ConvertActivityClient operations2 = new ConvertActivityClientImpl();
   private UploadActivityClient operations3 = new UploadActivityClientImpl();
   final Settable<String> result = new Settable<String>();

   public void paginate() 
   {
     Promise<String> UDone = operations0.Upload(result);
     Promise<String> dnDone = operations1.s3Download(UDone);
     Promise<String> convDone = operations2.pdfToTiff(dnDone);
     operations3.s3Upload(convDone);
   }

   @Override
   public void signal1(String data)  {
      // result.set(data);
       //result.Void();
       Promise<String> ready = Promise.asPromise("ready");
       result.chain(ready);
   }


}

此处活动上载等待对象结果处于就绪状态。因此,当我发信号通知工作流程时,方法signal1启动并将对象置于就绪状态。 但是,只要我发出工作流信号,工作流程执行就会失败。

我使用nodejs aws api来表示工作流程。下面是相同的代码 -

var AWS = require('aws-sdk');
AWS.config.update({accessKeyId: '', secretAccessKey: ''});
AWS.config.update({region: 'us-east-1'});

var swf = new AWS.SWF();
var params = {
  domain: 'HWdemo2', /* required */
  signalName: 'signal1', /* required */
  workflowId: 'PaginationWorkflow', /* required */
  //input: 'true'
  //runId: 'STRING_VALUE'
};
swf.signalWorkflowExecution(params, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
});

我在AWS工作流事件控制台中显示的执行失败的错误如下 -

&#13;
&#13;
["java.util.concurrent.CancellationException", {
  "cause": ["java.lang.NullPointerException", {
    "cause": null,
    "stackTrace": [{
      "methodName": "<init>",
      "fileName": null,
      "lineNumber": -1,
      "className": "java.io.StringReader",
      "nativeMethod": false
    }, {
      "methodName": "createParser",
      "fileName": "JsonFactory.java",
      "lineNumber": 835,
      "className": "com.fasterxml.jackson.core.JsonFactory",
      "nativeMethod": false
    }, {
      "methodName": "readValue",
      "fileName": "ObjectMapper.java",
      "lineNumber": 2098,
      "className": "com.fasterxml.jackson.databind.ObjectMapper",
      "nativeMethod": false
    }, {
      "methodName": "fromData",
      "fileName": "JsonDataConverter.java",
      "lineNumber": 96,
      "className": "com.amazonaws.services.simpleworkflow.flow.JsonDataConverter",
      "nativeMethod": false
    }, {
      "methodName": "signalRecieved",
      "fileName": "POJOWorkflowDefinition.java",
      "lineNumber": 111,
      "className": "com.amazonaws.services.simpleworkflow.flow.pojo.POJOWorkflowDefinition",
      "nativeMethod": false
    }, {
      "methodName": "doExecute",
      "fileName": "AsyncDecider.java",
      "lineNumber": 417,
      "className": "com.amazonaws.services.simpleworkflow.flow.worker.AsyncDecider$1",
      "nativeMethod": false
    }, {
      "methodName": "",
      "fileName": "",
      "lineNumber": 0,
      "className": "--- continuation ---",
      "nativeMethod": false
    }, {
      "methodName": "handleWorkflowExecutionSignaled",
      "fileName": "AsyncDecider.java",
      "lineNumber": 413,
      "className": "com.amazonaws.services.simpleworkflow.flow.worker.AsyncDecider",
      "nativeMethod": false
    }, {
      "methodName": "processEvent",
      "fileName": "AsyncDecider.java",
      "lineNumber": 251,
      "className": "com.amazonaws.services.simpleworkflow.flow.worker.AsyncDecider",
      "nativeMethod": false
    }, {
      "methodName": "decide",
      "fileName": "AsyncDecider.java",
      "lineNumber": 496,
      "className": "com.amazonaws.services.simpleworkflow.flow.worker.AsyncDecider",
      "nativeMethod": false
    }, {
      "methodName": "handleDecisionTask",
      "fileName": "AsyncDecisionTaskHandler.java",
      "lineNumber": 50,
      "className": "com.amazonaws.services.simpleworkflow.flow.worker.AsyncDecisionTaskHandler",
      "nativeMethod": false
    }, {
      "methodName": "pollAndProcessSingleTask",
      "fileName": "DecisionTaskPoller.java",
      "lineNumber": 201,
      "className": "com.amazonaws.services.simpleworkflow.flow.worker.DecisionTaskPoller",
      "nativeMethod": false
    }, {
      "methodName": "run",
      "fileName": "GenericWorker.java",
      "lineNumber": 94,
      "className": "com.amazonaws.services.simpleworkflow.flow.worker.GenericWorker$PollServiceTask",
      "nativeMethod": false
    }, {
      "methodName": "runWorker",
      "fileName": null,
      "lineNumber": -1,
      "className": "java.util.concurrent.ThreadPoolExecutor",
      "nativeMethod": false
    }, {
      "methodName": "run",
      "fileName": null,
      "lineNumber": -1,
      "className": "java.util.concurrent.ThreadPoolExecutor$Worker",
      "nativeMethod": false
    }, {
      "methodName": "run",
      "fileName": null,
      "lineNumber": -1,
      "className": "java.lang.Thread",
      "nativeMethod": false
    }],
    "message": null,
    "localizedMessage": null,
    "suppressed": ["[Ljava.lang.Throwable;", []]
  }],
  "stackTrace": [{
    "methodName": "execute",
    "fileName": "POJOWorkflowDefinition.java",
    "lineNumber": 66,
    "className": "com.amazonaws.services.simpleworkflow.flow.pojo.POJOWorkflowDefinition",
    "nativeMethod": false
  }, {
    "methodName": "doAsync",
    "fileName": "AsyncDecider.java",
    "lineNumber": 70,
    "className": "com.amazonaws.services.simpleworkflow.flow.worker.AsyncDecider$WorkflowExecuteAsyncScope",
    "nativeMethod": false
  }],
  "message": null,
  "localizedMessage": null,
  "suppressed": ["[Ljava.lang.Throwable;", []]
}]
&#13;
&#13;
&#13;

任何人都可以帮我解决这个错误,非常感谢提前。

2 个答案:

答案 0 :(得分:0)

默认情况下,如果无法反序列化信号参数,则工作流执行将失败。默认情况下,JsonDataConverter由工作流决策程序使用,该决策程序在Jackson之上实现。它期望JSON文档具有特定格式。学习此格式的最简单方法是使用生成的Java界面发送信号并查看工作流历史记录。然后,您可以在JavaScript代码中重现它。

答案 1 :(得分:0)

工作流期望输入对象数组,可以将其转换为字符串作为json。