是否有某种标准配置设置、服务或工具可以接受来自一个队列的消息并将其移至另一个队列?自动处理死消息问题,并提供一些重试能力?我认为这就是“MSMQ 消息路由”的作用,但似乎找不到有关它的文档(Windows Mobile 6 除外,我不知道这是否相关)。
上下文:
据我了解,在使用 MSMQ 时,您应该始终写入本地队列,以便不太可能出现故障,然后 X 应该将该消息移动到远程队列。我的理解有错吗?这就是像 Biztalk 这样的消息传递基础设施的用武之地吗?是否有必要先写入本地队列才能绝对确保成功?我应该自己构建 X 吗?
Is there some standard configuration setting, service, or tool that accepts messages from one queue and moves them on to another one? Automatically handling the dead message problem, and providing some of retry capability? I was thinking this is what "MSMQ Message Routing" does but can't seem to find documentation on it (except for on Windows Mobile 6, and I don't know if that's relevant).
Context:
I understand that when using MSMQ you should always write to a local queue so that failure is unlikely, and then X should move that message to a remote queue. Is my understanding wrong? Is this where messaging infrastructure like Biztalk comes in? Is it unnecessary to write to a local queue first to absolutely ensure success? Am I supposed to build X myself?
发布评论
评论(2)
正如 Hugh 指出的那样,您只需要一个 MSMQ 队列即可从源到目的地单向发送消息。源和目标可以位于同一服务器、同一网络或跨 Internet,但是源和目标都必须运行 MSMQ 服务。
如果您需要进行“消息”路由(例如,处理来自多个源或目标队列的消息的交换机,或者根据消息类型将消息路由到一个或多个订阅者等),您将需要的不仅仅是 MSMQ 队列。
虽然您当然可以使用 BizTalk 进行消息路由,但如果您不需要使用 BizTalk 的其他功能,这将是昂贵的/过度杀伤力。建议您查看开源软件,或者自己构建一些自定义的东西。
但是,通过“路由”,您可能指的是使用 HTTP 作为传输(例如通过互联网)时的队列重定向功能(例如 此处 和 此处)。
回复:失败的传递和重试
我认为您已经掌握了大部分概念 - 一般来说,消息 DELIVERY 重试功能应该隐含在 MSMQ 中。如果 MSMQ 无法在定义的到期之前传递消息,那么它将在死信队列中返回,然后源可以处理来自 DLQ 的消息,然后对它们进行“补偿”(例如,反转“发送”的操作,向用户指示失败等)。
然而,目标中的“处理”类型重试需要由目标应用程序/侦听器执行(例如,如果目标系统出现故障、死锁等)
执行此操作的常见方法包括:
然而,在大多数情况下,无限期的处理重试是不可取的,您最终需要承认失败并实现一种机制来记录消息和错误并将其从队列中删除。
但我不会“重试”业务失败(例如业务规则、验证等),并且行为应该在您如何处理这些的要求中定义(例如帐户透支、消息格式不正确或无效等) ),例如通过向源返回“NACK”类型消息。
华泰
As Hugh points out, you need only one MSMQ Queue to Send messages in one direction from a source to a destination. Source and destination can be on the same server, same network or across the internet, however, both source and destination must have the MSMQ service running.
If you need to do 'message' routing (e.g. a switch which processes messages from several source or destination queues, or routing a message to one or more subscribers based on the type of message etc) you would need more than just MSMQ queue.
Although you certainly can use BizTalk to do message routing, this would be expensive / overkill if you didn't need to use other features of BizTalk. Would recommend you look at open source, or building something custom yourself.
But by "Routing" you might be referring to the queue redirection capability when using HTTP as the transport e.g. over the internet (e.g. here and here).
Re : Failed delivery and retry
I think you have most of the concepts - generally the message DELIVERY retry functionality should be implicit in MSMQ. If MSMQ cannot deliver the message before the defined expiry, then it will be returned on the Dead Letter Queue, and the source can then process messages from the DLQ and then 'compensate' for them (e.g. reverse the actions of the 'send', indicate failure to the user, etc).
However 'processing' type Retries in the destination will need to be performed by the destination application / listener (e.g. if the destination system is down, deadlocks, etc)
Common ways to do this include:
However, in most cases, indefinite processing retries are not desirable and you would ultimately need to admit defeat and implement a mechanism to log the message and the error and remove it from the queue.
But I wouldn't 'retry' business failures (e.g. Business Rules, Validation etc) and the behaviour should be defined in your requirements of how to handle these (e.g. account is overdrawn, message is not in a correct format or not valid, etc), e.g. by returning a "NACK" type message back to the source.
HTH
MSMQ 将消息从一个队列发送到另一个队列。
假设您在远程计算机上有一个队列。您想向该队列发送消息。
所以你创建了一个发件人。发送方是可以使用 MSMQ 传输来发送消息的应用程序。这可以是 .Net 队列客户端 (System.Messaging)、WCF 服务使用者(通过 netMsmqBinding 或 msmqIntegrationBinding、使用 MSMQ 适配器的 BizTalk 等)。
您发送消息时,实际发生的情况是:
在某些情况下,MSMQ 会遇到由于某种原因而无法在目标队列上接收的消息。在这些情况下,如果您已指示消息将使用死信队列,那么MSMQ将确保消息被转发到死信队列。
MSMQ sends messages from one queue to another queue.
Let's say you have a queue on a remote machine. You want to send a message to that queue.
So you create a sender. A sender is an application that can use the MSMQ transport to send a message. This can be a .Net queue client (System.Messaging), a WCF service consumer (either over netMsmqBinding or msmqIntegrationBinding, BizTalk using the MSMQ adapter, etc etc.
When you send the message, what actually happens is:
In certain situations MSMQ will encounter messages which for some reason or another cannot be received on the destination queue. In these situations, if you have indicated that a message will use the dead-letter queue then MSMQ will make sure that the message is forwarded to the dead-letter queue.