This sample demonstrates how to use Windows Azure Service Bus to send and receive messages from a queue.
The queue provides decoupled, asynchronous communication between a sender and any number of receivers (here, a single receiver).
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.
Sample Flow
The sample flows in the following manner:
- Start a sender.
- Sender prompts for user Service Bus credentials.
- Sender creates queue.
- Sender sends messages to queue.
- Start a receiver.
- Receiver retrieves messages from the queue.
- Close receiver.
- Close sender (deletes queue).
Running the Sample
To run the sample:
- Build the solution in Visual Studio.
- Run the sender, inputting service namespace, issuer name, and issuer key when prompted to do so.
- Run the receiver, inputting service namespace, issuer name, and issuer key when prompted to do so.
Expected Output - Sender
Please provide the service namespace to use: <service_namespace> Please provide the issuer name to use: <issuer_name> Please provide the issuer key to use: <issuer_key> Creating Queue 'IssueTrackingQueue'... Sending messages to Queue... Message sent: Id = 1, Body = First message information Message sent: Id = 2, Body = Second message information Message sent: Id = 3, Body = Third message information After running the entire sample, press ENTER to clean up and exit. |
Expected Output - Receiver
Please provide the service namespace to use: <service_namespace> Please provide the issuer name to use: <issuer_name> Please provide the issuer key to use: <issuer_key> Receiving messages from Queue 'IssueTrackingQueue'... Message received: Id = 1, Body = First message information Message received: Id = 2, Body = Second message information Message received: Id = 3, Body = Third message information End of scenario, press ENTER to exit. |