views:

86

answers:

3

I have different environments for my application (Dev -> Test -> Prod), and I'm using MSMQ.

I also have the name of the queues (they are remote queues) I use via config files, in the following format:

FormatName:Direct=SERVER_NAME\Private$\MY_QUEUE

My problem is that SERVER_NAME is different in the different environments, and I'd like to delegate that problem to the server (ie: for databases I have aliases with the same name in all 3 servers, and they each point to the actual db server)

I tried adding the queue server to the hosts file, but it failed with the following error:

The queue does not exist or you do not have sufficient permissions to perform the operation.

I tried FormatName:Direct, FormatName:OS, and FormatName:TCP

Any help (workaround, new ideas, how to make that work) would be highly appreciated.

The objective is to have a single config file that would work in all environments.

A: 

The formatnames that you have specified are not valid. It should be:

FormatName:Direct=OS:SERVER_NAME\Private$\MY_QUEUE

or if you want to use the IP adress instead:

FormatName:Direct=TCP:XXX.XXX.XXX.XXX\Private$\MY_QUEUE
Kjell-Åke Andersson
I tried all that, as it says in my question...
Juan Manuel
+1  A: 

This is just a guess, and I can't verify this at this moment, but:

The reason for the failure is that msmq uses kerberos authentication. Which authenticate both side of the exchange. Your side is accessing the server with the "wrong" name. So when the server tries to authenticate with you(the client). Windows can "tell" that this is not the server you are looking for. So it fails the authentication.

There are probably ways to circumvent that. But it will compromise security. What I would suggest is to put the three names of the destination servers (dev, qa and production) in the config file. And choose between them with some parameter like domain name, user name, computer name or something other like that that is also different in you different environment.

Igal Serban
Interesting suggestion, hadn't thought of that
Juan Manuel
+1  A: 

We are also using a hosts file in our environment and found out (the hard way) that MSMQ does not support it. Our solution is to use an abstraction layer (ITransport) over MSMQ, and let this layer replace host names (that might be found in a hosts file) with ip addresses. It is easily done using the Dns class.

Omer Mor
Excellent, I can replace the string to connect to the queue with the ip by reading it with the Dns class!
Juan Manuel