简体   繁体   English

WCF / MQSeries:如何保存有毒消息

[英]WCF/MQSeries: How do you keep a poison message

I have a WebSphere MQ contract that I've setup. 我已经设置了WebSphere MQ合同。 I have the queue configured to deliver a message that is retried 5 times to a separate queue for poison processing. 我将队列配置为将重试5次的邮件传递到单独的队列进行毒药处理。 I interact with the service using the WCF Channel provided by WebSphere MQ v 7.01. 我使用WebSphere MQ v 7.01提供的WCF Channel与服务进行交互。

While my service is connected, things work perfectly. 连接我的服务后,一切运行正常。 As soon as the service disconnects, the poison messages reappear in the primary queue. 服务断开连接后,有害消息会再次出现在主队列中。 Restarting the service instantly puts the messages back from the primary queue into the poison queue. 立即重新启动服务会将消息从主队列放回毒物队列。 What do I need to do in order to get the messages to stay in the poison queue after the service disconnects from the queue? 服务从队列断开连接后,我该怎么办才能使消息保留在中毒队列中?

The code is currently in POC mode, so I'm hosting the service on a Window. 该代码当前处于POC模式,因此我将服务托管在Window上。 The class has these attributes: 该类具有以下属性:

  [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
  [AssuredDelivery()]
  public partial class MainWindow : Window, IWmqEndpoint

Service contract is: 服务合同是:

  [ServiceContract()]
  public interface IWmqEndpoint
  {
    [OperationContract(IsOneWay = true)]
    void SendMessage(string message);

    [OperationContract(IsOneWay = true)]
    void SendComplex(PersonName name);
  }

The main queue is persistent, otherwise, default settings. 主队列是持久性的,否则为默认设置。 Ditto for the poison queue. 毒药队列也一样。

Queue setup: 队列设置:

  1. Backout request queue: wcf.inbound.poison 回退请求队列:wcf.inbound.poison
  2. Backout threshold: 5 回退阈值:5
  3. Harden get backout: Not hardened 加强退出:未加强
  4. NPM class: Normal NPM类别:普通

When an application reads a message inside of a unit of work, WMQ has no idea whether there are any other messages in the same unit of work. 当应用程序读取工作单元内部的消息时,WMQ不知道同一工作单元中是否还有其他消息。 If the message turns out to be a poison message, WMQ requeues it to the backout queue in the same unit of work as everything else . 如果该消息被证明是有害消息,则WMQ将其重新排队到与其他所有工作单元相同的工作单元中的退出队列。 If WMQ were to move the message outside a unit of work, there's a chance it could be lost or duplicated. 如果WMQ将消息移到工作单元之外,则可能会丢失或重复该消息。 If WMQ committed the UOW on your behalf then there's a chance it could commit messages you've retrieved but not completely processed. 如果WMQ代表您提交了UOW,则它有可能提交您已检索但未完全处理的消息。 So WMQ makes you explicitly commit between units of work if performing backout processing. 因此,如果执行回退处理,WMQ使您可以在工作单元之间明确地提交。

The behavior you are seeing sound like the messages are being held on the backout queue under syncpoint. 您所看到的行为听起来像消息被保留在同步点下的退出队列中。 When the app is shut down an implicit BACKOUT occurs and all the messages go back to their original queue. 当应用程序关闭时,将发生隐式的BACKOUT ,所有消息均返回其原始队列。 You need at least one successful unit of work to make the messages stay in the backout queue. 您需要至少一个成功的工作单元才能使消息保留在退出队列中。 Try putting a good message on the input queue behind the bad ones and then execute an explicit COMMIT . 尝试在输入队列中的坏消息之后输入好消息,然后执行显式的COMMIT

By the way, WebSphere MQ does not have the concept of a persistent queue. 顺便说一下,WebSphere MQ没有持久队列的概念。 Persistence is an attribute of the message. 持久性是消息的属性。 The queue has an attribute DEFPSIST which tells the app whether to make a message persistent or not when the message is first created. 队列具有属性DEFPSIST ,该属性告诉应用程序在首次创建消息时是否使消息持久化。 Persistence of the message will not change as it travels throughout the WMQ network, regardless of the setting of the queues it passes through. 消息的持久性不会随着它在整个WMQ网络中传播而改变,而不管它通过的队列的设置如何。 Therefore, DEFPSIST on the backout queue has no effect whatsoever since the message persistence was defined before it hit the backout queue. 因此,回退队列上的DEFPSIST无效,因为消息持久性是在到达回退队列之前定义的。

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

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