0
votes

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.

1
It turns out that this was being caused by the WCF binding timeouts being too short. Once I increased the timeouts on both the client and server, it started working perfectly. The one point that I'm still confused about is that no errors were thrown on the client or server indicating this issue. Any idea as to why this wouldn't throw an error?Summit

1 Answers

3
votes

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.