WCF MSMQ 消息处理多次

发布于 2024-11-09 13:57:51 字数 822 浏览 4 评论 0原文

我有一个通过 MSMQ 进行通信的 WCF 程序。 由于某种原因,多条消息在没有明显原因的情况下被多次处理。没有抛出任何错误,并且我已确认应用程序进入和退出操作行为时没有抛出任何错误。

例如,我将通过 MSMQ 发送 1 条消息,应用程序将接收它并成功处理它,然后出于某种原因再次重新处理它(有时多次,有时不重新处理)

是定义的相关行为和契约:

[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)
      {
      }



    }

以下 就好像多次处理的 MSMQ 消息的中止计数 > 0 或被放入重试队列中,但是,我从未收到关于为什么会发生这种情况的错误。

任何关于为什么会发生这种情况的想法将不胜感激。

I have a WCF program that is being communicated with via 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.

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)

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.

Any idea as to why this would happen would be much appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

命比纸薄 2024-11-16 13:57:51

您发现您的问题是超出了绑定超时,并且您询问为什么在客户端或服务代码中没有看到任何异常。对此的解释如下:对于

客户端而言,消息是一种方式并已成功传递到队列。从客户的角度来看,这才是最重要的。客户端永远不会看到服务器端处理消息时出现异常。

在服务方面,您没有在代码中看到异常,因为超时是在 WCF 运行时级别处理的。您的代码正常完成其执行(WCF 不会中止正在执行的线程或任何内容),但就 WCF 运行时而言,它花费了太长时间,因此需要再次重试消息传递。也就是说,您肯定会在事件日志中看到错误,如果启用,还会在服务跟踪日志中看到指示发生超时的错误。

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. 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. That said, you most definitely will see errors in the event log and, if enabled, the service trace logs indicating that a timeout occurred.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文