开发者

Connecting to a remote queue via the hosts file

I have different environments for my application (Dev -> Te开发者_Python百科st -> 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.


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.


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.


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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜