我有下面的代码用于在 Azure 服务总线中创建队列
var cs = azureServiceBusConnectionString;
var namespaceManager = NamespaceManager.CreateFromConnectionString(cs);
if (namespaceManager.QueueExists(queueName))
{
namespaceManager.DeleteQueue(queueName);
}
var que = namespaceManager.CreateQueue(queueName);
que.EnablePartitioning = true;
我的队列创建正常,但我有 2 个问题
1) 即使我将 EnablePartioning 设置为 true,我的队列也将 EnablePartioning 设置为 false。为什么是这样?有没有我必须调用的方法来保存更改或其他内容 2)我无法设置队列的大小,因为 SizeInBytes 属性是只读的。我怎样才能做到这一点?
我没有看到任何允许我设置 EnablePartitioning 或大小的构造函数?
保罗
最佳答案
创建队列时,您应该在 QueueDescription
上启用分区。
var cs = azureServiceBusConnectionString;
var namespaceManager = NamespaceManager.CreateFromConnectionString(cs);
if (namespaceManager.QueueExists(queueName))
{
namespaceManager.DeleteQueue(queueName);
}
var queueDescription = new QueueDescription(queueName);
queueDescription.EnablePartitioning = true;
queueDescription.MaxSizeInMegabytes = 1024;
var que = namespaceManager.CreateQueue(queueDescription);
您无法设置 SizeInBytes
,因为它基于队列中消息的数量和大小。设置它没有任何意义。
您可以使用 MaxSizeInMegabytes
属性设置最大队列大小。
关于c# - C# 中的 Azure 服务总线队列创建未设置 EnablePartioning 或大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50050200/