销售电话: 1-800-867-1380

ViaPartitionKey 属性

注:本页面内容可能不完全适用中国大陆地区运营的 Windows Azure服务。如要了解不同地区 Windows Azure 服务的差异, 请参考本网站.

将使用事务通过传输队列发送消息时,获取或设置分区键值。

命名空间:  Microsoft.ServiceBus.Messaging
程序集:  Microsoft.ServiceBus(在 Microsoft.ServiceBus.dll 中)

public string ViaPartitionKey { get; set; }

属性值

类型:System..::..String
要使用事务通过传输队列发送消息时的分区键值。

Service Bus supports sending messages to a partitioned queue or topic via a partitioned transfer queue. In this case, the regular partition key (SessionId, PartitionKey, or MessageId) of the message is used for the destination queue or topic. If the transfer queue is partitioned and the ViaPartitionKey property is set, then the ViaPartitionKey value is used as a partition key for the transfer queue. If the ViaPartitionKey property is not set, then Service Bus uses an internal algorithm to assign messages to the fragments of the transfer queue.

If a transaction is used to send messages via a transfer queue, the ViaPartitionKey property must be set on these messages. If a single transaction is used to send multiple messages via a same transfer queue, the ViaPartitionKey property of all messages must be set to the same value.

MessageSender viaMessageSender = messagingfactory.CreateMessageSender(transferDestinationEntityPath: targetQueue.Path, viaEntityPath: transferQueue.Path);
CommittableTransaction committableTransaction = new CommittableTransaction();
using (TransactionScope ts = new TransactionScope(committableTransaction))
{
    BrokeredMessage msg = new BrokeredMessage("This is a message");
    msg.ViaPartitionKey = "myPartitionKey"; // Used as a partition key for transfer queue.
    msg.SessionId = "mySessionId"; // Used as a partition key for destination queue.
    viaMessageServer.Send(msg); 
    ts.Complete();
}
committableTransaction.Commit();
本文是否对您有所帮助?
(1500 个剩余字符)
感谢您的反馈

社区附加资源

添加
显示:
© 2014 Microsoft