Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MSMQ::GetPrivateQueuesByMachine fails when using "localhost"

Tags:

c#

msmq

I have software running locally and on a number of servers that does the following:

var queues = MessageQueue.GetPrivateQueuesByMachine("localhost");

One server in particular throws an exception:

System.Messaging.MessageQueueException: Message Queue service is not available.
  at System.Messaging.MessageQueue.GetPrivateQueuesByMachine(String machineName)

MSMQ is installed the same as it is on my other machines. I also have multiple WCF Services successfully bound to net.msmq://localhost/private/....

Is there some reason that MSMQ might not be bound to localhost?

After checking out MSDN, it seems that I should be using ".", which works great, but I'd rather avoid changing code and redeploying, when localhost seems to be totally efficient. FWIW, here are the results of some other tests I ran:

var queues = MessageQueue.GetPrivateQueuesByMachine("."); // succeeds
var queues = MessageQueue.GetPrivateQueuesByMachine("localhost"); // fails
var queues = MessageQueue.GetPrivateQueuesByMachine("127.0.0.1"); // fails
var queues = MessageQueue.GetPrivateQueuesByMachine("machineName"); // fails
like image 812
Langdon Avatar asked Nov 14 '22 01:11

Langdon


1 Answers

There is likely to be a HOSTS file entry mapping localhosts IP address to some machine name.

like image 177
John Breakwell Avatar answered Dec 22 '22 11:12

John Breakwell