Export (0) Print
Expand All
2 out of 2 rated this helpful - Rate this topic

Service Bus Queues

Updated: March 13, 2014

Queues provide messaging capabilities that enable a large and heterogeneous class of applications running on premises or in the cloud to exchange messages in a flexible, secure and reliable fashion across network and trust boundaries.

Windows Azure Queues

Queues are hosted in Windows Azure by a replicated, durable store infrastructure. The maximum size of a queue is 5GB. The maximum message size is instead 256KB, but the use of sessions allows you to create unlimited-size sequences of related messages. Queues are accessed through the following APIs:

  1. The new messaging API available through the new Microsoft.ServiceBus.Messaging assembly.

  2. Windows Communication Foundation (WCF) through the new NetMessagingBinding class.

  3. Service Bus REST API.

Queue entities provide the following capabilities:

  1. Session-based correlation, allowing you to build multiplexed request/reply paths easily.

  2. Reliable delivery patterns using the PeekLock receive mode.

  3. Transactions support to ensure that batches of messaging operations (both send and receive) are committed atomically.

  4. Detection of inbound message duplicates, allowing clients to send the same message multiple times without adverse consequences.

  5. Dead-letter facility for messages that cannot be processed or expire before being received.

  6. Deferring messages for later processing. This functionality is particularly handy in the following cases:

    1. When messages are received out of the expected sequence and need to be saved while a process waits for a particular message to permit further progress.

    2. When messages must be processed based on a set of properties that define their priorities during a traffic peak.

In the .NET API the message entity is modeled by the BrokeredMessage class, which exposes properties (such as MessageId, SessionID, and CorrelationId) that you can use to exploit capabilities such as automatic duplicate detection or session-enabled communications. You can use a QueueDescription object to specify the metadata that models the behavior of the queue being created:

  1. The DefaultMessageTimeToLive property specifies the default message time-to-live value.

  2. The DuplicateDetectionHistoryTimeWindow property defines the duration of the duplicate detection history.

  3. The EnableDeadLetteringOnMessageExpiration property allows you to enable or disable the dead-letter facility on message expiration.

  4. The LockDuration property defines the duration of the lock used by a consumer when using the PeekLock receive mode. In the ReceiveAndDelete receive mode, a message is deleted from the queue as soon as a consumer reads it. Conversely, in the PeekLock receive mode, a message is hidden from other receivers until the timeout defined by the LockDuration property expires. By that time the receiver should have deleted the message invoking the Complete method on the BrokeredMessage object.

  5. The MaxSizeInMegabytes property defines the maximum queue size in megabytes.

  6. The RequiresDuplicateDetection property enables\disables duplicate message detection. The RequiresSession property enables\disables sessions.

  7. The MessageCount return the number of messages in the queue. This is property is extremely useful because, based on its value, an intelligent system can decide to increase or decrease the number of competing consumers that concurrently receive and processes messages from the queue.

Since metadata cannot be changed once a messaging entity is created, modifying the duplicate detection behavior requires deleting and recreating the queue. The same principle applies to any other metadata.

Using queues permits you to flatten highly-variable traffic into a predictable stream of work and distribute the load across a set of worker processes size of which can vary dynamically to accommodate the incoming message volume. In a competing consumers scenario, when a publisher writes a message to a queue, multiple consumers compete with each other to receive the message, but only one of them will receive and process the message in question.

In service-oriented or service bus architecture composed of multiple, heterogeneous systems, interactions between autonomous systems are asynchronous and loosely-coupled. In this context, the use of messaging entities like queues and topics (see the next section) allows increasing the agility, scalability and flexibility of the overall architecture and helps decreasing the loose coupling of individual systems.

See Also

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

© 2014 Microsoft. All rights reserved.