Amazon SQS:如何找到作业结束?
假设我有很多工作,每个工作都由许多工作应用程序所处理的大量基本操作组成。
我将每个操作的消息发送给工作人员,以便他们可以捕获这些消息,执行所需的操作,然后使用控制队列中的消息通知某些控制应用程序。
但我怎么知道所有操作都完成了呢? SQS 消息是无序的,所以我不能只发送“最后”消息。
Let's say I have a lot of jobs and every job consists from a big number of some elementary operations that many worker applications work upon.
I send a message for every operation to workers, so they can catch these messages, do what is needed, then notify with a message in a control queue some control application.
But how can I know that all operations are done? SQS messages are out-of-order, so I cannot just send a "last" message.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
考虑到消息不仅可能无序,而且还可能由于各种原因而完全失败,因此,如果问题确实存在,您通常会添加消息和特定于作业的序列号。
例如;您提交的第一个作业由三个项目组成,因此它是作业 1-3-1、1-3-2 和 1-3-3。在这个假设的编号方案中,作业 1 由三个部分组成,并且由三个部分组成。当主机收到 131 和 133 时,它“知道”它正在等待 132 以完成作业。如果在一段时间内没有收到,它甚至可以重新发出请求。
像这样的一些方案可以防止您的请求和请求片段混淆。
祝你好运
Given not only that messages may be out of order, but that they may fail altogether for various reasons, you generally therefore add both message and job-specific serial numbers if your problem warrants.
For example; the first job you submit consists of three items, so it is jobs 1-3-1, 1-3-2 and 1-3-3. In this hypothetical numbering scheme Job 1, consisting of three parts, and the three parts. When the master receives 131 and 133 it "knows" that it is waiting on 132 in order to complete the job. If it does not receive it in some duration, it could even reissue the request.
Some scheme like this would keep your requests and request fragments from getting mixed up.
Good Luck