2
votes

I have a WCF service where client applications can connect via a MSMQ:

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

and then:

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);

with the following configuration:

  <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>

I have the service with the same configuration already in use without problems on other installations. But now on a new installation I receive only messages from some clients (9 actually - there are 31). The messages I receive are always from the same servers. I can't find an error message anywhere (Windows Event Log (Client/Server), WCF Trace file) and also the MSMQ state says "connected" on the client machines that don't send messages. The dead letter queues are also empty.

The messages must get lost somewhere between the MSMQ Client and Server (I stopped my app and on the server queue I received only messages from the nine Clients - same behaviour if I enable journaling).

Any help would be appreciated

Update

I've used performance counters to monitor the queue. The session counter shows the correct value of 31 sessions. Also the incoming message counter shows correct values. However if I stop the app or enable journaling only a part of the messages are stored in the queue.

1
You've found a link to a KB article that relates to MSMQ 1.0/Windows NT 4.0. I know that one shouldn't assume, but is that really the environment that you're working in?Damien_The_Unbeliever
No, that's the only information I've found. The OS is a Windows Server 2008 R2 DatacenterJeldrik
I just looked at one of my old Wcf/Msmq examples. The only thing that jumps out to me is the "void Update(DataSet ds);". Are you sure the ds are under the max size? DataSets are notorious for bloat. Can you write a temp Method to take a string (and maybe each client can sent a unique value) and write out a temp/txt file or something. as a test?granadaCoder
@granadaCoder: Thanks for the comment. I guess you mean the 4MB limit of the MSMQ message size? The messages form all servers should be about the same size (and are about 40k bytes), so I think it must have a different reason.Jeldrik

1 Answers

1
votes

The problem comes through cloning the server as described in this blog entry: http://blogs.msdn.com/b/johnbreakwell/archive/2007/02/06/msmq-prefers-to-be-unique.aspx

Basically it says there that you must not clone servers with MSMQ feature turned on. If you do so you either have to re-install the MSMQ feature on your client machines or do a registry change:

1.Stop the MSMQ Service
2.Delete the QMId value completely
3.Add a SysPrep DWORD (Under HKLM\Software\Microsoft\MSMQ\Parameters) and set it to 1
4.Start the MSMQ Service