如何保证azure队列的先进先出
我了解 MS Azure 队列服务文档 http://msdn.microsoft.com /en-us/library/windowsazure/dd179363.aspx 表示不保证先出 (FIFO) 行为。
然而,我们的应用程序必须按 FIFO 顺序读取和处理所有消息。有人可以建议如何使用 Azure 队列服务实现有保证的 FIFO 吗?
谢谢。
I understand that MS Azure Queue service document http://msdn.microsoft.com/en-us/library/windowsazure/dd179363.aspx says first out (FIFO) behavior is not guaranteed.
However, our application is such that ALL the messages have to be read and processed in FIFO order. Could anyone please suggest how to achieve a guaranteed FIFO using Azure Queue Service?
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
docs 表示:
也许这对你来说已经足够了?否则使用服务总线。
The docs say for Azure Storage queues that:
Maybe that is good enough for you? Else use Service bus.
最新的服务总线版本提供可靠的消息队列:队列、主题和订阅
The latest Service Bus release offers reliable messaging queuing: Queues, topics and subscriptions
不幸的是,许多答案误导了服务总线队列,但我认为问题是关于提到的标签中的存储队列。在
Azure 存储队列
中,不保证 FIFO,而在Service Bus
中,保证 FIFO 消息排序,而且也只能使用一个称为会话的概念。一个简单的场景可能是,如果任何消费者从队列中接收到一条消息,当您作为第二个接收者时,它对您来说是不可见的。因此,您假设收到的第二条消息实际上是第一条消息(其中 FIFO 失败:P)
如果这不是您的要求,请考虑使用服务总线。
Unfortunately, many answers misleads to Service Bus Queues but I assume the question is about Storage Queues from the tags mentioned. In
Azure Storage Queues
, FIFO is not guranteed, whereas inService Bus
, FIFO message ordering is guaranteed and that too, only with the use of a concept called Sessions.A simple scenario could be, if any consumer receives a message from the queue, it is not visible to you when you are the second receiver. So you assume the second message you received is actually the first message (Where FIFO failed :P)
Consider using Service Bus if this is not your requirement.
添加到 @RichBower 答案...查看此...Azure 存储队列与 Azure 服务总线队列
MSDN(链接已停用)
http://msdn.microsoft.com/en-us/library/ windowsazure/hh767287.aspx
learn.microsoft.com
https://learn.microsoft.com/en-us/azure/service-bus-messaging/service-bus-azure-and-service-bus-queues-compared-contrasted
Adding to @RichBower answer... check out this... Azure Storage Queues vs. Azure Service Bus Queues
MSDN (link retired)
http://msdn.microsoft.com/en-us/library/windowsazure/hh767287.aspx
learn.microsoft.com
https://learn.microsoft.com/en-us/azure/service-bus-messaging/service-bus-azure-and-service-bus-queues-compared-contrasted
我不知道您希望处理消息的速度有多快,但是如果您需要有一个真正的 FIFO,请不要允许 Azure 的队列一次获取多于一条消息。
在函数顶部的“program.cs”中使用它。
这将一次收到一条消息,等待时间为 100 毫秒。
这与记录器网络作业完美配合,将 traze 信息写入文件。
I don't know how fast do you want to process the messages, but if you need to have a real FIFO, don't allow Azure's queue to get more than one message at a time.
Use this at your "program.cs" at the top of the function.
This will get one message at a time with a wait period of 100 miliseconds.
This is working perfectly with a logger webjob to write to files the traze information.
正如这里提到的 https:/ /www.jayway.com/2013/12/20/message-ordering-on-windows-azure-service-bus-queues/ 服务中也不保证排序总线,除了使用有风险的接收和删除模式
As mentioned here https://www.jayway.com/2013/12/20/message-ordering-on-windows-azure-service-bus-queues/ ordering is not guaranteed also in service bus, except of using recieve and delete mode which is risky
您只需要按照以下步骤来确保消息排序:
1) 创建一个会话启用= false 的队列。
2) 在队列中保存消息时,提供会话 ID,如下所示:-
3) 创建接收者以恢复消息时:-
4) 当具有相同的会话 ID 时,它会自动确保顺序并给出有序消息。
谢谢!!
You just need to follow below steps to ensure Message ordering.:
1) Create a Queue with session enabled=false.
2) While saving message in the queue, provide the session id like below:-
3) While creating receiver for reviving message:-
4) While having the same session id, it would automatically ensure order and give the ordered message.
Thanks!!