【问题标题】:MSMQ receives messages only from some ClientsMSMQ 只接收来自某些客户端的消息
【发布时间】:2015-03-22 06:07:57
【问题描述】:

我有一个 WCF 服务,其中客户端应用程序可以通过 MSMQ 进行连接:

[ServiceContract(Namespace="http://example.com", SessionMode = SessionMode.NotAllowed)]
public interface IMyService
{
    [OperationContract(IsOneWay = true)]
    void Update(DataSet ds);
}

然后:

string queueName = ConfigurationManager.AppSettings["QueueName"];
NetMsmqBinding binding = new NetMsmqBinding("MyBinding");

if (!MessageQueue.Exists(@".\private$\" + queueName))
{
    MessageQueue.Create(@".\private$\" + queueName, binding.ExactlyOnce);
}

ServiceHost msmqHost = new ServiceHost(typeof(MyService));
msmqHost.AddServiceEndpoint(typeof(IMyService), binding, "net.msmq://localhost/private/" + queueName);

具有以下配置:

  <system.serviceModel>
    <bindings>
      <netMsmqBinding>
        <binding name="MyBinding" durable="false" exactlyOnce="false" maxReceivedMessageSize="20000000">
          <security mode="None" />
          <readerQuotas maxDepth="32" maxStringContentLength="543192" maxArrayLength="2147483647" maxBytesPerRead="4096" maxNameTableCharCount="8456384" />
        </binding>
      </netMsmqBinding>
    </bindings>
    <services>
      <service name="MyService" behaviorConfiguration="MsMqBehavior" />
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="MsMqBehavior">
          <serviceThrottling maxConcurrentCalls="50" maxConcurrentSessions="50" maxConcurrentInstances="50" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

我已经在使用具有相同配置的服务,在其他安装上没有问题。但现在在新安装中,我只收到来自一些客户端的消息(实际上是 9 个 - 有 31 个)。我收到的消息总是来自相同的服务器。我在任何地方都找不到错误消息(Windows 事件日志(客户端/服务器)、WCF 跟踪文件),并且 MSMQ 状态在不发送消息的客户端计算机上显示“已连接”。死信队列也是空的。

消息必须在 MSMQ 客户端和服务器之间的某处丢失(我停止了我的应用程序,并且在服务器队列上我只收到了来自九个客户端的消息 - 如果我启用日志记录,行为相同)。

任何帮助将不胜感激

更新

我使用性能计数器来监控队列。会话计数器显示 31 个会话的正确值。传入消息计数器也显示正确的值。但是,如果我停止应用程序或启用日记功能,则只有部分消息存储在队列中。

【问题讨论】:

  • 您找到了与 MSMQ 1.0/Windows NT 4.0 相关的知识库文章的链接。我知道人们不应该假设,但这真的是你工作的环境吗?
  • 不,这是我找到的唯一信息。操作系统是 Windows Server 2008 R2 数据中心
  • 我刚刚查看了一个旧的 Wcf/Msmq 示例。唯一让我想到的是“void Update(DataSet ds);”。你确定ds低于最大尺寸吗?数据集因臃肿而臭名昭著。你能写一个 temp 方法来获取一个字符串(也许每个客户端都可以发送一个唯一的值)并写出一个 temp/txt 文件或其他东西。作为测试?
  • @granadaCoder:感谢您的评论。我猜你的意思是 MSMQ 消息大小的 4MB 限制?来自所有服务器的消息应该大小相同(大约 40k 字节),所以我认为它一定有不同的原因。

标签: wcf msmq


【解决方案1】:

问题来自克隆服务器,如此博客条目中所述:http://blogs.msdn.com/b/johnbreakwell/archive/2007/02/06/msmq-prefers-to-be-unique.aspx

基本上它说你不能克隆打开了 MSMQ 功能的服务器。如果这样做,您要么必须在客户端计算机上重新安装 MSMQ 功能,要么进行注册表更改:

1.停止 MSMQ 服务
2.彻底删除QMId值
3.添加一个 SysPrep DWORD(在 HKLM\Software\Microsoft\MSMQ\Parameters 下)并将其设置为 1
4.启动MSMQ服务

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-01-23
    • 1970-01-01
    • 2013-03-28
    • 1970-01-01
    • 2020-10-15
    • 1970-01-01
    • 2015-09-09
    • 1970-01-01
    相关资源
    最近更新 更多