MSMQ Messages sent to DNS alias to 127.0.0.1 ending up on Outgoing Queue instead of local queue

719 views Asked by At

I'm using msmqIntegrationBinding to send messages to a legacy MSMQ. I want to be able to use the same config file in preprod as we do in production, but in preprod the legacy queue is local whereas the production queue is on another server.

I thought I could do it with a DNS alias.

I've set up a DNS alias in the HOSTS file on my preprod server to 127.0.0.1

127.0.0.1 CRM_SERVER

I've configured the endpoint in the client to use a DIRECT OS formatname using the DNS alias

 <endpoint name="LegacyMsmqService" 
           address="msmq.formatname:DIRECT=OS:CRM_SERVER\crmintegration" 
           binding="msmqIntegrationBinding" 
           contract="Integration.Facades.ILegacyMsmqService" 
           bindingConfiguration="msmqIntegrationBinding"/>

I've set the HKEY_LOCAL_MACHINE\Software\Microsoft\MSMQ\Parameters\IgnoreOSNameValidation registry key to 1, and I've even add CRM_SERVER to the HKEY_Local_Machine\System\CurrentControlSet\Services\LanmanServer\Parameters\OptionalNames key.

I've restarted at least a dozen times!

Whenever my client sends a message to the queue, it's ending up on an Outgoing Queue, not on the local queue. Using the correct machine name or localhost works fine.

Have I missed something?

1

There are 1 answers

0
Geoffrey McGrath On

To resolve via DNS use the DNS name rather than the IP this way:

FORMATNAME:Direct=OS:CRM_SERVER\crmintegration

As you noted in your question, it is important to set the IgnoreOSNameValidation paramater on MSMQ client (your preprod machine is both client and server) (per http://support.microsoft.com/kb/306785). Here is a command line way to do that:

reg.exe ADD HKLM\Software\Microsoft\MSMQ\Parameters /V IgnoreOSNameValidation /t REG_DWORD /d 1 /f

or if you prefer, by powershell:

Set-ItemProperty -Path HKLM:\Software\Microsoft\MSMQ\Parameters -Name IgnoreOSNameValidation -Value 1

NOTE: inserting into QUEUE entries can resolve using TCP protocol in the format name instead--but for reading from the queue you cannot use TCP (recall the MSMQ is old tech):

FORMATNAME:Direct=TCP:CRM_SERVER\crmintegration