Getting Started with Windows Azure Service Bus (2) queuing (queue)

Source: Internet
Author: User
Tags app service windows azure sdk azure sdk

Windows Azure Platform Family of articles Catalog

 Service Bus queues (queue)

The queue for Service bus is ideal for distributed applications. When a service Bus queue is used, the components of the distributed application do not communicate directly.

-Front End application ( sender ) creates an azure Service Bus Queue, inserts the message body that needs to be processed, and then continues to process the front-end business logic

-Back-end message processing ( receiver ) takes the message out of the service Bus queue and processes it

-The sender does not need to wait for a reply from the receiving party to process and send more messages on the front end

-The Azure Service Bus queue is first out, and the message body that is initially added is first processed. and the service Bus queue is handled by multiple receivers , similar to competitive mode. At the same time, however, a message body is processed by only one receiver and is guaranteed not to be processed repeatedly by multiple receivers .

This is like the author into the restaurant to eat, waiter (on behalf of the author as the sender) to help the author a la carte, Cook (on behalf of the recipient) in the kitchen cooking. Assuming that the restaurant has ABC three chefs, the dish will be competed by ABC three chefs, the first dish is first processed (FIFO), and the same dish will be made by only one chef, not by two or more cooks at the same time.

Service Bus Queue Frame composition:

  

The Service Bus queue is a common technique that can be used in a variety of scenarios:

    1. Communication before web role and service Bus Worker role in a multi-tiered (multi-tier) Azure application
    2. Hybrid cloud solutions for communicating with each other in azure public and enterprise intranet applications
    3. Communication between distributed applications of different organizations or departments in the enterprise intranet

Using the service Bus queue allows you to better extend your application and make the architecture more flexible.

Next, I'll describe creating and using Azure Service Bus Queue using Azure Management Portal and Visual Studio 2013来.

Prerequisites to prepare for this demo:

    1. Windows Azure Global Account (www.windowsazure.com)
    2. Visual Studio 2013
    3. Windows Azure SDK (I am using. NET SDK for VS2013)

  

1. First we need to login to Azure Management Portal (http://manage.windowsazure.com)

2. Click Custom Create, Service Bus->queue, new, App service. Set the name and namespace of the service bus. Such as:

  

Then configure Azure Service Bus, such as:

  

, you can set up information such as Max size for Azure Service Bus queue as needed, and the author temporarily uses the default settings.

  

3. Once created, we can view the service bus access key through the connection information of the display bar, such as:

  

The key appears as follows:

  

  The above completes the service Bus namespace setting.

4. Then we open VS2013 as an administrator. Click View-and Server Explorer on the toolbar.

In Server Explorer, expand Windows Azure, Service Bus, and then right-click Add New Connection

  

In the, tick the use connection string, and then copy the access key connection string that we have in step three:

  

  

5. After setting up, we expand service Bus, Leizhangservicebus-ns, Queues, then click on the queue, right button, Create New queue. Such as:

In the pop-up window, set name to Leizhangservicebusqueue.

Then expand the contents of the queues to see the azure Service Bus Queue that we created successfully.

  

Periodic summary:

Step 1-3 for creating the Azure Service Bus namespace

Step 4-5, implementing the work of creating an azure Service Bus queue

Next, we're going to test through Visual Studio 2013, send and receive messages to the service Bus Queue.

1. We click on Create a successful service Bus Queue, right-click Send a test message to send a message to the test, such as:

  

2. A pop-up window proves that the test message was sent successfully. Such as:

  

3. Repeat step 1 of the Send a test message three times.

4. Go back to Azure Management Portal and click Leizhangservicebus-ns to see that the queue length is 3 because in step 3, we send a test message executed three times. Such as:

  

5. Next, we perform the steps to receive the message. We right-click on "Receive Message"

  

6. When you click Receive Message, the results of the receive messages are displayed.

As you can see, next week the ID is 1, which is the first message. Explains that the service Bus queue is first-in-first-out, and that the label's time 4:32:36 PM and the time of Step 2 coincide, and that the first message is accepted. Such as:

  

7. Repeat the receive message for step 5 until all Azure Service Bus message is removed.

8. Then we go back to the azure Management Portal and we can see that the queue length becomes 0 again, because I receive the message of the service Bus queue through VS2013. Such as:

  

Getting Started with Windows Azure Service Bus (2) queuing (queue)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.