简体   繁体   English

MSMQ中的事务队列可能出现乱序消息?

[英]Out of order messages possible with transactional queues in MSMQ?

I'm new to messaging and a little unclear as to whether it is possible for MSMQ to deliver out-of-order messages for transactional queues. 我是消息传递的新手,有点不清楚MSMQ是否有可能为事务队列提供无序消息。 I suppose it must be because if a message is not processed correctly (and since we will be using multiple "competing consumers"), then other consumers could continue to process messages while the failed message is placed back on queue. 我想这一定是因为如果消息没有正确处理(并且因为我们将使用多个“竞争消费者”),那么其他消费者可以继续处理消息,同时将失败的消息放回队列。 Just can't seem to find a black-and-white answer anywhere on this. 似乎无法在任何地方找到黑白答案。

  • Negative black-and-white answer are hard to find( they don't often exist). 消极的黑白答案很难找到(它们通常不存在)。
  • You are confusing two terms here( I think). 你在这里混淆了两个词(我想)。 delivery is from the sender to the queue. 交付是从发件人到队列。 consuming is from the queue to the consumer. 消费是从队列到消费者。 Those two action can't be put in the same transaction. 这两个动作不能放在同一个交易中。 They are totally separate action ( this is one of the points of queuing ) 它们是完全独立的动作(这是排队的一个点)

More to the point: from " Microsoft Message Queuing Services (MSMQ) Tips " 更重要的是:来自“ Microsoft消息队列服务(MSMQ)提示

That these messages will either be sent together, in the order they were sent, or not at all. 这些消息将按照发送顺序一起发送,或者根本不发送。 In addition, consecutive transactions initiated from the same machine to the same queue will arrive in the order they were committed relative to each other. 此外,从同一台机器发起到同一队列的连续事务将按照它们相对于彼此提交的顺序到达。

This is the only case of order in msmq. 这是msmq中唯一的订单情况。

Sadly you won't find anything about ordered consuming because its not relevant. 可悲的是,你不会发现有关订购消费的任何信息,因为它不相关。 You can consume messages from msmq any way you want. 您可以以任何方式使用来自msmq的消息。

Update: If you must have ordered processing, than I don't see the reason to use many consumers. 更新:如果你必须有订单处理,我没有看到使用许多消费者的原因。 You will have to implement the order in your code. 您必须在代码中实现订单。

Do your messages need to be processed in order because: 您的邮件是否需要按顺序处理,因为:

1) They are different steps of a workflow? 1)它们是工作流程的不同步骤? If so, you should create different queues to handle the different steps. 如果是这样,您应该创建不同的队列来处理不同的步骤。 Process 1 reads Queue 1, does its thing, then writes to Queue 2, and so forth. 进程1读取队列1,执行其操作,然后写入队列2,依此类推。

2) They have different priorities? 2)他们有不同的优先事项? If the priority levels are fairly coarse (and the order of messages within priorities doesn't matter), you should create high-priority and low-priority queues. 如果优先级相当粗略(并且优先级内的消息顺序无关紧要),则应创建高优先级和低优先级队列。 Consumers read from the higher priority queues first. 消费者首先从优先级较高的队列中读取。

3) A business rule specifies it. 3)业务规则指定它。 For example, "customer orders must be processed in the order they are received." 例如,“客户订单必须按收到的顺序处理。” Message queues are not appropriate for this kind of sequencing since they only convey the order in which messages are received. 消息队列不适合这种排序,因为它们只传达接收消息的顺序。 A process that periodically polls a database for an ordered list of tasks would be more suitable. 定期轮询数据库以获取有序任务列表的进程更为合适。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM