This sample demonstrates communication between MSMQ and the Service Bus using a bridge.
There are 3 executables in this sample. The intention of the sample is to showcase a simple implementation of MSMQ-to-ServiceBus bridge using the Bridge project. The MsmqTestClient and ServiceBusTestClient projects are client projects used for testing the bridge.
The functionalities of the executables are:
- The MsmqTestClient program acts as a setup utility as well as an MSMQ test client. It creates all the queues (both MSMQ and Service Bus), and sends/receives messages from MSMQ queues using System.Messaging APIs. When all the messages are sent and received, the program deletes the queues.
- The ServiceBusTestClient program sends/receives messages from Service Bus queues using Service Bus APIs.
- The Bridge program is the MSMQ-ServiceBus bridge that can send messages from an MSMQ queue to a Service Bus queue and vice-versa. The bridge in this sample is a simple implementation that is tied to a fixed MsmqQueue and a Service Bus queue. It can be made generic in nature by enumerating queues in MSMQ and Service Bus to achieve an automatic bridging capability. However, it is not the intention of this sample to showcase an all-purpose bridge between MSMQ and Service Bus.
The sequence of steps performed by the sample are as below:
- The MsmqTestClient program creates all the necessary queues (MSMQ queues - MsmqSendQueue/MsmqReceiveQueue, Service Bus queues - ServiceBusSendQueue/ServiceBusReceiveQueue)
- The MsmqTestClient program sends a Message to a MSMQ queue (MsmqSendQueue)
- The Bridge reads this MSMQ message from the MSMQ queue (MsmqSendQueue), converts the message a into BrokeredMessage and sends it to a Service Bus queue (ServiceBusSendQueue)
- The ServiceBusTestClient program receives the BrokeredMessage from the Service Bus queue (ServiceBusSendQueue) and sends the BrokeredMessage back through another ServiceBus queue (ServiceBusReceiveQueue)
- The Bridge receives the BrokeredMessage from this Service Bus queue (ServiceBusReceiveQueue) and sends an MSMQ message to another MSMQ queue (MsmqReceiveQueue)
- The MsmqTestClient program receives the MSMQ message from the second MSMQ queue (MsmqReceiveQueue)
- The MsmqTestClient program deletes all the queues
Note: The sample demonstrates simple communication between MSMQ and Service Bus. It does not deal with acknowledgements for the messages being sent. |
Prerequisites
If you haven't already done so, please read the release notes document that explains how to sign up for a Windows Azure account and how to configure your environment.
To install MSQM, please refer to Installing Message Queuing (MSMQ).
Running the Sample
After building the solution, run the executables in the following order.
- MsmqTestClient.exe
- Bridge.exe
- ServiceBusTestClient.exe
Each will prompt for a Service Bus service namespace, issuer name (e.g. "owner"), and issuer key.
When finished, the MsmqTestClient will prompt to press ENTER to clean up queues and exit the application.
Did you find this information useful?