我正在尝试向一个主题发送消息,该主题是在选中启用重复检测和启用分区选项的情况下创建的。我没有在我的 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);
}
关于.net - Azure 服务总线主题分区,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44845716/