英文:
How Do I Receive The Response From new StepFunctionsStartExecution In AWS CDK?
问题
使用场景:
- 在步骤函数1中遍历子项
- 将每个JSON对象发送到步骤函数2
- 在步骤函数2结束时,它会收到来自第三方API的响应
- 在步骤函数1中使用该API响应
图像:
代码:
this.mapOverChildren = new Map(this, "Map Over Children", {
itemsPath: "$.data.children",
maxConcurrency: 1,
resultPath: "$.children",
});
this.mapOverChildren.iterator(new StepFunctionsStartExecution(this, 'Send Data to Step Function 2', {
stateMachine: stepFunction.Two,
integrationPattern: IntegrationPattern.REQUEST_RESPONSE,
resultPath: "$.stepFunctionTwoResponse"
});
目前,resultPath
只显示有关步骤函数执行的信息。如何从步骤函数2中获取数据?
resultPath:
{
"ExecutionArn": "xxxxxxxxxxxx",
"SdkHttpMetadata": {
"AllHttpHeaders": {
"x-amzn-RequestId": [
"xxxxxxxxxxx"
],
"Content-Length": [
"000"
],
"Date": [
"Thu, 23 Feb 2023 11:24:14 GMT"
],
"Content-Type": [
"application/xxxxxxxxxxxxxxxxxxxxxxx"
]
},
"HttpHeaders": {
"Content-Length": "111",
"Content-Type": "application/xxxxxxxxxxxxxxxxxxxxxxx",
"Date": "Thu, 23 Feb 2023 11:24:14 GMT",
"x-amzn-RequestId": "xxxxxxxxxxxxxxxxxxxxxxx"
},
"HttpStatusCode": 200
},
"SdkResponseMetadata": {
"RequestId": "xxxxxxxxxxxxxxxxxxxxxxx"
},
"StartDate": 1677151454840
}
英文:
Use-Case:
- Map over the children in Step Function 1
- Send each JSON object to Step Function 2
- At the end of Step Function 2, it receives a response from a third-party API
- Use that API response in Step Function 1
Image:
Code:
this.mapOverChildren = new Map(this, "Map Over Children", {
itemsPath: "$.data.children",
maxConcurrency: 1,
resultPath: "$.children",
});
this.mapOverChildren .iterator(new StepFunctionsStartExecution(this, 'Send Data to Step Function 2', {
stateMachine: stepFunction.Two,
integrationPattern: IntegrationPattern.REQUEST_RESPONSE,
resultPath: "$.stepFunctionTwoResponse"
});
At the momement, the resultPath
is just showing information about the step function execution. How do I get the data back from Step Function 2?
resultPath:
{
"ExecutionArn": "xxxxxxxxxxxx",
"SdkHttpMetadata": {
"AllHttpHeaders": {
"x-amzn-RequestId": [
"xxxxxxxxxxx"
],
"Content-Length": [
"000"
],
"Date": [
"Thu, 23 Feb 2023 11:24:14 GMT"
],
"Content-Type": [
"application/xxxxxxxxxxxxxxxxxxxxxxx"
]
},
"HttpHeaders": {
"Content-Length": "111",
"Content-Type": "application/xxxxxxxxxxxxxxxxxxxxxxx",
"Date": "Thu, 23 Feb 2023 11:24:14 GMT",
"x-amzn-RequestId": "xxxxxxxxxxxxxxxxxxxxxxx"
},
"HttpStatusCode": 200
},
"SdkResponseMetadata": {
"RequestId": "xxxxxxxxxxxxxxxxxxxxxxx"
},
"StartDate": 1677151454840
}
答案1
得分: 2
REQUEST_RESPONSE
是一个错误的集成模式,如果您想等待子步骤函数完成并使用其结果,应使用RUN_JOB
。
英文:
https://docs.aws.amazon.com/step-functions/latest/dg/connect-to-resource.html
REQUEST_RESPONSE
is the wrong integration pattern to use if you want to wait for the sub stepfunction to finish and use its result, use RUN_JOB
instead.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论