博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Azure Queue 和 Service Bus Queue的比较
阅读量:5085 次
发布时间:2019-06-13

本文共 5750 字,大约阅读时间需要 19 分钟。

 
编码

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

转载于:https://www.cnblogs.com/ericwen/archive/2012/12/25/2831708.html

你可能感兴趣的文章
javascript和json
查看>>
模板方法模式 - 大学新生报到案例
查看>>
jsonp小案例
查看>>
深入浅出----I2C
查看>>
postgresql获取表最后更新时间(通过触发器将时间写入另外一张表)
查看>>
OC3_选择器
查看>>
MySQL Join 的实现原理
查看>>
Java多线程 阻塞队列和并发集合
查看>>
不再让内容把td撑开
查看>>
Leetcode刷题笔记——n-sum问题
查看>>
shell scripts的简单使用二
查看>>
scrapy的Middleware
查看>>
linux命令
查看>>
webpack打包
查看>>
shell习题第15题:看数字找规律
查看>>
poj 3748 位操作
查看>>
priority_queue的用法
查看>>
iOS沙盒路径的查看和使用
查看>>
陈嘉 2015/07/16 个人文档
查看>>
朱晔的互联网架构实践心得S1E7:三十种架构设计模式(上)
查看>>