如何更改服务总线队列的属性? [英] How to change the properties of a service bus queue?

查看:122
本文介绍了如何更改服务总线队列的属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用服务总线队列Web角色和辅助角色之间的通信。有时候,Web角色的消息不是由工人角色接受。但它立即接受下一个消息我送。所以,我因为批处理操作启用想也许它的发生。我一直在试图把它放到假的,但我还没有取得成功。这是我的code。

I am using service bus queues to communicate between web role and worker role. Sometimes web role messages are not being accepted by worker role. But it immediately accepts the next message i send. So i was thinking maybe its happening because the Batched Operations is enabled. I have been trying to put it to false but i havent been successful. This is my code.

public static QueueClient GetServiceBusQueueClient(string queuename)
    {            
        string connectionString;

        if (RoleEnvironment.IsAvailable)
         connectionString = CloudConfigurationManager.GetSetting("Microsoft.ServiceBus.ConnectionString");
        else
            connectionString = ConfigurationManager.AppSettings["Microsoft.ServiceBus.ConnectionString"];          


        var namespaceManager = NamespaceManager.CreateFromConnectionString(connectionString);

        QueueDescription queue = null;

        if (!namespaceManager.QueueExists(queuename))
        {
            queue = namespaceManager.CreateQueue(queuename);
            queue.EnableBatchedOperations = false;
            queue.MaxDeliveryCount = 1000;
        }
        else
        {
            queue = namespaceManager.GetQueue(queuename);
            queue.EnableBatchedOperations = false;
            queue.MaxDeliveryCount = 1000;
        }

        MessagingFactorySettings mfs = new MessagingFactorySettings();
        mfs.NetMessagingTransportSettings.BatchFlushInterval = TimeSpan.Zero;

        string issuer;
        string accessKey;
         if (RoleEnvironment.IsAvailable)
            issuer = RoleEnvironment.GetConfigurationSettingValue("AZURE_SERVICEBUS_ISSUER");
         else
             issuer = ConfigurationManager.AppSettings["AZURE_SERVICEBUS_ISSUER"];

        if (RoleEnvironment.IsAvailable)
            accessKey = RoleEnvironment.GetConfigurationSettingValue("AZURE_SERVICEBUS_ACCESS_KEY");
        else
            accessKey = ConfigurationManager.AppSettings["AZURE_SERVICEBUS_ACCESS_KEY"];

        mfs.TokenProvider = TokenProvider.CreateSharedSecretTokenProvider(issuer, accessKey);
        MessagingFactory messagingFactory = MessagingFactory.Create(namespaceManager.Address, mfs);

        QueueClient Client = messagingFactory.CreateQueueClient(queue.Path);            

        return Client;
    }

但EnableBatchedOperations始终是真实的MaxDeliveryCount始终为10默认。

But the EnableBatchedOperations is always true and the MaxDeliveryCount is always 10 by default.

让我知道如果你知道有什么问题。

Let me know if you know what's the issue

感谢

推荐答案

如果你想设置的 EnabledBatchedOperations ,你必须做的创建队列。你这样做,通过创建一个 QueueDescription 对象,然后传递到 createQueue方法方法。例如:

If you want to set the EnabledBatchedOperations, you have to do that before you create the queue. you do that by creating a QueueDescription object then pass that to the CreateQueue method. For example:

QueueDescription orderQueueDescription =
    new QueueDescription(queuename)
    {
        RequiresDuplicateDetection = true,
        MaxDeliveryCount = 1000,
    };
namespaceMgr.CreateQueue(orderQueueDescription);

更新:

该文档是pretty清楚这个:

Update:

The documentation is pretty clear on this:

由于元数据不能更改一次创建一个消息的实体,修改重复检测行为,需要删除并重新创建队列。同样的原则也适用于任何其他元数据。 [1]

Since metadata cannot be changed once a messaging entity is created, modifying the duplicate detection behavior requires deleting and recreating the queue. The same principle applies to any other metadata. [1]

QueueDescription 重新presents队列的元数据描述。

[1] http://msdn.microsoft.com/en -us /库/ windowsazure / hh532012.aspx

这篇关于如何更改服务总线队列的属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆