I have a program that sends MSMQ messages to a remote machine.
This works fine.
However, during debugging we will run the program on a number of different machines, and on the remote server there is an issue receipting the message as the mappings etc. are not set up for our development machines.
What I would like to do is be able to specify a machine to send the MSMQ messages from; one that has the required mappings so the remote machine would receipt messages correctly.
Currently I create a queue using this path: FormatName:DIRECT=http://the.remote.machine.co.uk/msmq/frommycompany.
I then send messages by creating message objects and sending them within a transaction.
How can I send the messages to the remote machine from a machine other than the one the program is running on, so that the remote machine can receipt the messages correctly?
If I understood the problem correctly, I suggest to use a service that acts as a router.
You might want to use a WCF service that gets called by all clients from your development machines first and then acts itself as the only client who sends messages into your target machine. WCF is well suited to send the messages into the queue(s) with built-in functionality.
Alternatively – or in combination – you could consider using some messaging framework such as NServiceBus that makes your life working with MSMQ much easier.
NServiceBus gives you a lot of flexibility to configure where your messages should go to and who should subscribe to them. Most this can simply be set up in the application configuration files.