我如何最早确定AWS步骤函数状态是否失败?

发布于 2025-02-08 23:30:24 字数 438 浏览 3 评论 0 原文

我们正在对AWS步骤功能(状态机)实现工作流,该工作流程涉及用户记录的更新,并可能出现问题,以防万一出现问题。状态计算机会分为2个部分:

  1. PART1-更新
  2. Part2-回滚路径

在状态计算机采取回滚路径时,该过程需要很长时间。使客户等待这么长时间是无法接受的。但是,在开始回滚之前,可以通知客户。我试图找出一种实现这一目标的方法。

我已经尝试使用 Deficteexecution()。但是,只有在状态机执行后,失败状态才会更改为失败,这又很晚了。

我尝试在可能失败的点(部分和部分之间)插入“ SQS发送消息”步骤(部分和部分之间)。然后从编排函数(我的API端点的处理程序)中对该队列进行轮询。但是,这无法正常工作,因为我可能会并行运行100个请求,而SQS最终将失败。

感谢早期回应。

干杯。

We are implementing a workflow on aws step functions(state machine), that deals with update of user records and possible rollback in case something goes wrong. The state machine does processing in 2 parts:

  1. Part1 - updating
  2. Part2 - rollback

When rollback path is taken by the state machine, the process takes very long. Unacceptable to make the client wait this long. Just before starting the rollback however, the client could be informed. I am trying to figure out a way to achieve this.

I have already tried using describeExecution(). But the fail status changes to FAILED only after the state machine is done executing, which is again very late.

I tried inserting an "SQS send message" step at the point(between part1 and part2) where it is likely to fail. And then polling this queue from the orchestration function(handler of my API endpoint). However, this is not going to work as I may have 100s of requests running in parallel and SQS will eventually fail.

Appreciate an early response.

Cheers.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

横笛休吹塞上声 2025-02-15 23:30:24

首先,我建议您阅读步骤函数中的错误处理: https://docs.aws.amazon.com/step-functions/latest/dg/concepts-error andling.html

您可以使用后备状态(任务,映射,并行)并通过添加 catch 字段来捕获错误:

"Catch": [ {
   "ErrorEquals": [ "java.lang.Exception" ],
   "ResultPath": "$.error-info",
   "Next": "RecoveryState"
}, {
   "ErrorEquals": [ "States.ALL" ],
   "Next": "EndState"
} ]

如果您打算使用API​​来获取可以使用 getexecutionhistory 。它将返回事件列表,您可以检查返回的事件阵列中的失败。 ie

First I'd recommend you to read up on error handling in step functions: https://docs.aws.amazon.com/step-functions/latest/dg/concepts-error-handling.html .

You could use fallback states (Task, Map, Parallel) and catch the error by adding Catch field like so:

"Catch": [ {
   "ErrorEquals": [ "java.lang.Exception" ],
   "ResultPath": "$.error-info",
   "Next": "RecoveryState"
}, {
   "ErrorEquals": [ "States.ALL" ],
   "Next": "EndState"
} ]

If you are intending to use API to get the current state of the execution you could use GetExecutionHistory. It will return list of events and you can check the returned array of events for the failures. I.E. taskFailedEventDetails

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文