none
Can write to Custom Dead Letter Queue in MSMQ 5 with WCF MSMQ binding? RRS feed

  • Question

  • This seems like a pretty straight forward question, but there seems to be no straight forward answers on the web or in the forums. Can someone from Microsoft please respond to this question? Your MSDN documentation is out of date.

    In "Programming WCF Services" by Juval Lowy He states:

    With MSMQ 3.0 (xp, Server 2003) the dead letter queue is system wide. With MSMQ 4.0 (Vista, Server 2008, Windows 7) you can configure a service-specific DLQ.

    What about MSMQ 5 which is what I'm now running on my Windows 7 machine. Did they remove this feature? No matter what I try it always writes to the system wide transactional DLQ.

    Has anyone else had this issue? Here's my code. Thanks

    static void Main(string[] args)
            {
                ChannelFactory<IDoWorkProcessor> channelFactory = null;
                IDoWorkProcessor service = null;
    
                try
                {
                    var binding = new NetMsmqBinding(NetMsmqSecurityMode.None)
                    {
                       TimeToLive = new TimeSpan(0,0,30)
                        ,
                       CustomDeadLetterQueue = new Uri("net.msmq://localhost/private/doworkdeadletter")
                       
                       
                    };
                    var remoteAddress = new EndpointAddress("net.msmq://localhost/private/DoWorkTarget");
                    channelFactory = new ChannelFactory<IDoWorkProcessor>(binding,remoteAddress);
    
                    channelFactory.Open();
    
                    service = channelFactory.CreateChannel();
    
                    var clientChannel = service as IClientChannel;
    
    
                    if(null != clientChannel)
                        clientChannel.Open();
    
                    for (int i = 0; i < 10; i++)
                    {
                        using (var scope = new TransactionScope())
                        {
                            service.ProcessDoWorkItem(new DoWorkItem() { Name = "Name" + i.ToString(), WorkMilliseconds = 1000 });
                            scope.Complete();
                        }
                        
                    }
                }
                finally
                {
    
                    var clientChannel = service as IClientChannel;
                    if (null != clientChannel &&
                        CommunicationState.Opened == clientChannel.State)
                    {
                        clientChannel.Close();
                        clientChannel.Dispose();
                    }
    
                    if(null != channelFactory
                        && CommunicationState.Opened == channelFactory.State)
                        channelFactory.Close();
                }
    
                Console.WriteLine("Press any key to exit.");
                Console.ReadLine();
            }

    Wednesday, February 26, 2014 3:30 PM

Answers

  • Hi,

    The custom dead letter queue is only available in windows visa, please try to check the following:


    For more information, please try to refer to:
    #Dead Letter Queues:
    http://msdn.microsoft.com/en-us/library/ms752268(v=vs.110).aspx .


    Best Regards,
    Amy Peng

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, February 27, 2014 6:18 AM
    Moderator

All replies

  • Hi,

    The custom dead letter queue is only available in windows visa, please try to check the following:


    For more information, please try to refer to:
    #Dead Letter Queues:
    http://msdn.microsoft.com/en-us/library/ms752268(v=vs.110).aspx .


    Best Regards,
    Amy Peng

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, February 27, 2014 6:18 AM
    Moderator
  • The advice given on this thread (that custom dead letter queues are only available in Windows Vista) is incorrect, Microsoft never removed this feature from MSMQ.

    I felt it necessary to make a post here because this problem has been posed on other forums, and this thread typically ends up getting quoted as the "answer" on those forums as well.  Hopefully this clears up the issue.

    After the release of Windows Server 2008, Microsoft made some "security enhancements" to MSMQ which has made it behave differently than prior versions.  Newly created queues are no longer wide open to all for sending by default, which in effect, ends up blocking the MSMQ service itself from moving a message to a custom dead letter queue no matter what user the MSMQ service is running as (in my experience).  You will always end up with this error in your Application event logs:

    The message could not be moved to deadletter queue .\private$\[MyDLQ]. Check that queue exists and users have permissions to send. The message was moved to the system transactional dead letter queue. This event is logged at most once per 600 seconds. To change this setting, set \HKLM\Software\Microsoft\MSMQ\Parameters\Event2253 registry value to desired time in seconds. Error 0xc00e0025:

    I have thus far been unable to get MSMQ (no matter what identity the MSMQ service runs as) to move anything to a custom dead letter queue.  Doesn't matter how lax the restrictions are, it just never works.  Truth be told, there is a reason...it's just plain not supposed to work at all with this enhancement turned on.

    The solution is to simply make MSMQ behave the way it did before this enhancement was introduced (after you consider the security implications), which is shown at the bottom of this article:

    http://technet.microsoft.com/en-gb/library/cc731882(v=ws.10).aspx

    To quote the answer: To revert Message Queuing behavior to grant everyone send permissions for any newly created public and private queues by default, create the DWORD registry entry KEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSMQ\Parameters\Security\PermitAnonEveryoneSend and set to a value of 1.

    If you follow this advice, it should work again.  And be sure to restart MSMQ and then delete and recreate all affected queues after making this registry change.

    Hope this helps anyone who has struggled with this.






    • Proposed as answer by WCF Fanboy Sunday, September 28, 2014 5:16 PM
    • Edited by WCF Fanboy Sunday, September 28, 2014 10:21 PM
    Sunday, September 28, 2014 5:16 PM