다음을 통해 공유


Microsoft Azure Service Bus

Microsoft Azure Service Bus is a completely hosted and secure platform for messaging communication, event distribution and service publishing. Service bus provides an options for Windows Communication Foundation (WCF) and other services endpoints. Service Bus provides both relayed & brokered messaging communication model.

Relayed:

In relay service one-way, request/response and peer-to-peer messaging involves, The relayed service is used for bi-directional socket communication for increased point-to-point efficiency. Relayed messaging provides many benefits, but it only work when server and client both online on same time for sending and receiving messages, if any one of them is not online then the message will be lost.

Brokered:

Brokered messaging is durable, asynchronous and consist of Queues, Topics and Subscriptions. By using Service Bus it is not necessary that senders and receivers both must be online at the same time, it is reliable to store messages in a broker (like queue) until the receiver is ready to receive. This feature allows the distributed applications to be offline after completing their job, they don't take care either the other application is online or not for example due to some exception the application crash or due to some up-gradation if the application is not online the entire system still running, and when the offline system come online all the messages delivered to the application.

Queues:

Queues is message delivery mechanism which operates on First In, First Out (FIFO), by using Queues sender and receivers don't have to be online for sending and receiving the message at the same time, because messages are stored in queue, we uses Queues there where we don't wait for reply from the receiver in order to continue.

Queues also give benefits where we need to manage the load of the messages as well, because the processing time required for each message of work is constant. We can use queues where the applications are loosely coupled and sender and receiver are independent of each other. Sender or Receiver can be updated with out each other.

Following steps are involved in creation of Queue.

1. We need to use Microsoft.ServiceBus.NamespaceManager class to perform Queues and Topics.

  1. We need use user credentials and base address of the Service Bus namespace.

  2. We can create, enumerate and delete Queues & Topics by using NamespaceManager methods.

  3. You can create a new Queue by using a function Microsoft.ServiceBus.NamespaceManager.CreateQueue(Microsoft.ServiceBus.Messaging.QueueDescription) after creating an objects of Microsoft.ServiceBus.TokenProvider & service namespace management.

Topics and Subscriptions:

The message added into Queues can be used by only one receiver where as Topics and Subscriptions provide a one-to-many form of communication because it use "publish/subscribe" pattern. It is very much useful in case of large number of receivers, each published message is available to all the subscribers who subscribed for that Topic. The message is delivered to the Topic and then it delivered to all the Subscribers associated to the Topic depending upon filter rules which is set on a per-subscription basis. Sending message to the Topic is similar as we send message to the Queue the difference come on receiving end because in Topics it can only received to the subscribers.

Creating a Topic is similar to Queue, following steps are involved in creating a Topic.

1. Create the service URI.

  1. Create a Namespace client using NamespaceManager.

  2. Create a topic using Microsoft.ServiceBus.NamespaceManager.CreateTopic(System.String).