Comparison Criteria | Windows Azure Queues | Service Bus Queues |
Message Class Name | CloudQueueMessage | BrokeredMessage |
Send Method Name | CloudQueue.AddMessage() | QueueClient.Send()
|
Queue Size | ApproximateMessageCount |
|
How to Create Queue | // Retrieve storage account from connection string. CloudStorageAccount storageAccount = CloudStorageAccount.Parse( CloudConfigurationManager.GetSetting("StorageConnectionString")); // Create the queue client. CloudQueueClient queueClient = storageAccount.CreateCloudQueueClient(); // Retrieve a reference to a queue. CloudQueue queue = queueClient.GetQueueReference("myqueue"); // Create the queue if it doesn't already exist. queue.CreateIfNotExists(); | QueueDescription qd = new QueueDescription("TestQueue"); qd.MaxSizeInMegabytes = 5120; qd.DefaultMessageTimeToLive = new TimeSpan(0, 1, 0); // Create a new Queue with custom settings string connectionString = CloudConfigurationManager.GetSetting("Microsoft.ServiceBus.ConnectionString"); var namespaceManager = NamespaceManager.CreateFromConnectionString(connectionString); if (!namespaceManager.QueueExists("TestQueue")) { namespaceManager.CreateQueue(qd); } |
How to Send message | // Create a message and add it to the queue. CloudQueueMessage message = new CloudQueueMessage("Hello, World"); queue.AddMessage(message);
| string connectionString = CloudConfigurationManager.GetSetting("Microsoft.ServiceBus.ConnectionString"); QueueClient Client = QueueClient.CreateFromConnectionString(connectionString, "TestQueue"); Client.Send(new BrokeredMessage()); |
How to Receive Message | // Get the next message CloudQueueMessage retrievedMessage = queue.GetMessage(); //Process the message in less than 30 seconds, and then delete the message queue.DeleteMessage(retrievedMessage); | BrokeredMessage message = Client.Receive(); if (message != null) { try { // Remove message from queue message.Complete(); } catch (Exception) { // Indicate a problem, unlock message in queue message.Abandon(); } } |
Comparison Criteria | Windows Azure Queues | Service Bus Queues |
Ordering guarantee | No | Yes - First-In-First-Out (FIFO) (through the use of messaging sessions) |
Delivery guarantee | At-Least-Once | At-Least-Once At-Most-Once |
Transaction support | No | Yes (through the use of local transactions) |
Receive behavior | Non-blocking (completes immediately if no new message is found) | Blocking with/without timeout (offers long polling, or the “”) Non-blocking (through the use of .NET managed API only) |
Receive mode | Peek & Lease | Peek & Lock Receive & Delete |
Exclusive access mode | Lease-based | Lock-based |
Lease/Lock duration | 30 seconds (default) 7 days (maximum) | 60 seconds (default) 5 minutes (maximum) |
Lease/Lock granularity | Message level (each message can have a different timeout value) | Queue level (each queue has a lock granularity applied to all of its messages, fixed for the lifetime of the queue) |
Batched receive | Yes (explicitly specifying message count when retrieving messages, up to a maximum of 32 messages) | Yes (implicitly enabling a pre-fetch property or explicitly through the use of transactions) |
Batched send | No | Yes (through the use of transactions or client-side batching) |
Comparison Criteria | Windows Azure Queues | Service Bus Queues |
Scheduled delivery | Yes | Yes |
Automatic dead lettering | No | Yes |
Message deferral | Yes (via in-place update of visibility timeout) | Yes (provided via a dedicated API function) |
Poison message support | Yes | Yes |
In-place update | Yes | No |
Server-side transaction log | Yes | No |
Storage metrics | Yes | No |
Purge queue function | Yes | No |
Message groups | No | Yes (through the use of messaging sessions) |
Duplicate detection | No | Yes (configurable on the sender side) |
WCF integration | No | Yes (offers out-of-the-box WCF bindings) |
WF integration | Custom (requires building a custom WF activity) | Native (offers out-of-the-box WF activities) |
Comparison Criteria | Windows Azure Queues | Service Bus Queues |
Maximum message size | 64 KB (48 KB when using Base64 encoding) | 256 KB (including both header and body, maximum header size: 64 KB) |
Maximum queue size | 100 TB (limited to a single storage account capacity) | 1, 2, 3, 4 or 5 GB (defined upon creation of a queue) |
Maximum message TTL | 7 days | Unlimited |
Maximum number of queues | Unlimited | 10,000 (per service namespace, can be increased) |
Maximum number of concurrent clients | Unlimited | Unlimited (100 concurrent connection limit only applies to TCP protocol-based communication) |
Comparison Criteria | Windows Azure Queues | Service Bus Queues |
Management protocol | REST over HTTP/HTTPS | REST over HTTPS |
Runtime protocol | REST over HTTP/HTTPS | REST over HTTPS TCP with TLS |
.NET Managed API | Yes (.NET managed Storage Client API) | Yes (.NET managed brokered messaging API) |
Java API | Yes | Yes |
PHP API | Yes | Yes |
Node.js API | Yes | No |
Arbitrary metadata support | Yes | No |
Queue naming rules | Up to 63 characters long [3,63] (letters in a queue name must be lowercase) | Up to 260 characters long (queue names are case-insensitive) |
Get queue length function | Yes (approximate value) | Yes (exact, point-in-time value) |
Peek function | Yes | No |
Comparison Criteria | Windows Azure Queues | Service Bus Queues |
Maximum throughput | Up to 2,000 messages per second | Up to 2,000 messages per second (based on benchmark with 1 KB messages) |
Average latency | 10 ms (with disabled) | 100 ms |
Throttling behavior | Reject with HTTP 503 code (throttled requests are not treated as billable) | Reject with exception/HTTP 503 (throttled requests are not treated as billable) |
Comparison Criteria | Windows Azure Queues | Service Bus Queues |
Authentication | Symmetric key | ACS claims |
Role-based access control | No | Yes (through the use of ACS roles) |
Identity provider federation | No | Yes |
工作流程
Azure Queue Message 流程
Service Bus Queue