Azure 服务总线主题分区
Azure Service Bus topics partitioning
我正在尝试向创建的主题发送消息,该主题创建时同时选中了启用重复检测 和启用分区 选项。我没有在 BrokeredMessage
实例上设置 SessionId
和 PartitionKey
属性。根据this:
If the queue or topic has the
QueueDescription.RequiresDuplicateDetection property set to true and
the BrokeredMessage.SessionId or BrokeredMessage.PartitionKey
properties are not set, then the BrokeredMessage.MessageId property
serves as the partition key.
在我创建 BrokeredMessage
的实例后,它的 MessageId
属性 会自动初始化,所以我希望分区能够工作。但它没有:
Microsoft.Azure.WebJobs.Host.FunctionInvocationException: Exception
while executing function: Functions.ProcessQueueMessage2Async --->
System.InvalidOperationException: SessionId needs to be set for all
brokered messages to a Partitioned Topic that supports Ordering, Topic
Name = dev1-mtapp:Topic:response-topic~255.
TrackingId:5fbe5df2-8747-4053-ba79-c29a80e9d1ed_G25_B31,
SystemTracker:dev1-mtapp:topic:response-topic~255
我哪里错了?
您应该设置:
topicDescription.SupportOrdering = false.
例如:
if (!this.namespaceManager.TopicExists(topicName))
{
TopicDescription topicDescription = new TopicDescription(topicName);
topicDescription.SupportOrdering = false;
this.namespaceManager.CreateTopic(topicDescription);
}
我正在尝试向创建的主题发送消息,该主题创建时同时选中了启用重复检测 和启用分区 选项。我没有在 BrokeredMessage
实例上设置 SessionId
和 PartitionKey
属性。根据this:
If the queue or topic has the QueueDescription.RequiresDuplicateDetection property set to true and the BrokeredMessage.SessionId or BrokeredMessage.PartitionKey properties are not set, then the BrokeredMessage.MessageId property serves as the partition key.
在我创建 BrokeredMessage
的实例后,它的 MessageId
属性 会自动初始化,所以我希望分区能够工作。但它没有:
Microsoft.Azure.WebJobs.Host.FunctionInvocationException: Exception while executing function: Functions.ProcessQueueMessage2Async ---> System.InvalidOperationException: SessionId needs to be set for all brokered messages to a Partitioned Topic that supports Ordering, Topic Name = dev1-mtapp:Topic:response-topic~255. TrackingId:5fbe5df2-8747-4053-ba79-c29a80e9d1ed_G25_B31, SystemTracker:dev1-mtapp:topic:response-topic~255
我哪里错了?
您应该设置:
topicDescription.SupportOrdering = false.
例如:
if (!this.namespaceManager.TopicExists(topicName))
{
TopicDescription topicDescription = new TopicDescription(topicName);
topicDescription.SupportOrdering = false;
this.namespaceManager.CreateTopic(topicDescription);
}