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:

  1. Start a sender.
    1. Sender prompts for user Service Bus credentials.
    2. Sender creates queue.
    3. Sender sends messages to queue.
  2. Start a receiver.
    1. Receiver retrieves messages from the queue.
    2. Close receiver.
  3. Close sender (deletes queue).

Running the Sample

To run the sample:

  1. Build the solution in Visual Studio.
  2. Run the sender, inputting service namespace, issuer name, and issuer key when prompted to do so.
  3. 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.
                    

Did you find this information useful? Please send your suggestions and comments about the documentation.