简体   繁体   English

WCF MSMQ 消息处理多次

[英]WCF MSMQ message processed multiple times

I have a WCF program that is being communicated with via MSMQ.我有一个 WCF 程序正在通过 MSMQ 进行通信。 For some reason several messages are being processed multiple times for no apparent reason.由于某种原因,几条消息被多次处理,没有明显的原因。 No errors are being thrown and I've confirmed that the application enters and exits the operationBehaivior without any errors being thrown.没有抛出任何错误,我已经确认应用程序进入和退出 operationBehaivior 时没有抛出任何错误。

For example, I'll send 1 message via MSMQ, the app will receive it and successfully process it, then for some reason reprocess it again (sometimes multiple times, sometimes no reprocessing)例如,我将通过 MSMQ 发送 1 条消息,应用程序将收到它并成功处理它,然后由于某种原因再次对其进行重新处理(有时多次,有时不重新处理)

Here are the relevant behavior's and contracts being defined:以下是定义的相关行为和合同:

[ServiceContract]
public interface IApp
{

    [OperationContract(IsOneWay = true)]
    void ProcessMessage(List<AppData> appInfo);

}

[ServiceBehavior(InstanceContextMode=InstanceContextMode.Single)]
public class ProcessInfo : IApp
{
    [OperationBehavior(TransactionScopeRequired = true, TransactionAutoComplete = true)]
    public void ProcessMessage(List<AppData> appInfo)
    {
      try
      {
           app logic
      }
      catch(Exception e)
      {
      }



    }

It looks as though the MSMQ messages that are processed multiple times have an aborted count > 0 or are put in the retry queue, however, I never receive an error as to why this happens.看起来好像多次处理的 MSMQ 消息的中止计数 > 0 或被放入重试队列,但是,我从未收到关于为什么会发生这种情况的错误。

Any idea as to why this would happen would be much appreciated.任何关于为什么会发生这种情况的想法都将不胜感激。

You found out that your problem was the binding timeouts were being exceeded and you asked why you weren't seeing any exceptions in your client or service code.您发现您的问题是超出了绑定超时,并且您询问为什么在您的客户端或服务代码中没有看到任何异常。 Here's the explination for that:这是对此的解释:

Client wise, the message is one way and was successfully delivered to the queue.就客户端而言,消息是一种方式,并且已成功传递到队列。 That's all that matters from the client perspective.从客户的角度来看,这才是最重要的。 The client will never see that there was an exception in processing the message on the server side.客户端永远不会看到在服务器端处理消息时出现异常。

Service wise, you weren't seeing exceptions in your code because the timeout is handled at the WCF runtime level.服务方面,您没有在代码中看到异常,因为超时是在 WCF 运行时级别处理的。 Your code completes its execution normally (WCF isn't going to abort the executing thread or anything), but as far as the WCF runtime is concerned it took too long and so the message delivery needs to be retried again.您的代码正常完成其执行(WCF 不会中止正在执行的线程或任何东西),但就 WCF 运行时而言,它花费了太长时间,因此需要再次重试消息传递。 That said, you most definitely will see errors in the event log and, if enabled, the service trace logs indicating that a timeout occurred.也就是说,您肯定会在事件日志中看到错误,如果启用,服务跟踪日志会指示发生超时。

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

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