【问题标题】:Cannot add Messages to more than one Azure Queue at the time同时无法将消息添加到多个 Azure 队列
【发布时间】:2013-04-25 21:16:41
【问题描述】:

经过 5 个小时的尝试,我认为我的 Azure 帐户有问题,不允许我同时处理多个队列。

我首先创建两个队列,当然有两个小写的名称,然后我检查它们是否存在,并检查它们的 uri 名称,看起来没问题。

然后我开始向我的第一个队列添加一条消息,这工作正常,如果我检查队列有多少条消息,它会给我一个大于 0 的数字。

然后我重复完全相同的步骤将消息添加到我的第二个队列,但这次当我尝试检查消息计数时,它甚至没有说 0,它抛出 null。

如果我从第二个队列中使用 getMessage(),它也会返回一个空消息,这意味着我添加的所有消息实际上都不会进入我的第二个队列中的存储。

这取决于帐户是否有任何限制?我是否必须在 azure 上设置一些不同的东西才能让多个队列分区同时工作?

感谢您提前回复..

编辑

我在 WCF 中的一流定义为:

private static CloudQueue processedqueue;
private static CloudQueue notprocessedqueue;

这是我的 InitializeStorage 方法:

var queue1 = account.CreateCloudQueueClient();
                notprocessedqueue = queue1.GetQueueReference("notprocessedqueue");
                notprocessedqueue.CreateIfNotExist();
var queue2 = account.CreateCloudQueueClient();
                processedqueue = queue2.GetQueueReference("processedqueue");
                processedqueue.CreateIfNotExist();


//I have tried using queue1 to get the reference of both queues but is the same result

负责填队的方法:

   var message = new CloudQueueMessage(string.Format("{0},{1}", pWord, processed.ToString()));

    var message2 = new CloudQueueMessage(string.Format("{0},{1}", pWord, processed.ToString()));

processedqueue.AddMessage(message);
notprocessedqueue.AddMessage(message2);



processedqueue.Exists() <- Returns true
processedqueue.Uri.ToString() <- returns a proper URL with the name I defined in the getReference method
notprocessedqueue.Exists() <-  Retruns true 
notprocessedqueue.Uri.ToString() <- returns a proper URL with the name I defined in the getReference method

执行 addMessage 方法后,我尝试以下操作:

processedqueue.ApproximateMessageCount <- returns 1
notprocessedqueue.ApproximateMessageCount <- returns null

【问题讨论】:

  • 您是否尝试将完全相同的对象添加到另一个队列?如果您尝试以相反的顺序执行会发生什么。我感觉可能需要一些代码才能获得正确的答案
  • 它确实有效,也就是说,改变了我将消息添加到队列中的顺序。而且消息是不同的,我没有尝试将相同的消息添加到两个队列中,尽管目前它们出于测试目的而持有相同的消息
  • 你能给我们看一些代码吗?一般来说,这是可行的,但根据您的操作方式,您可能会遇到一些问题。
  • 我添加了我当前使用的代码
  • 你确定你复制的代码完全正确吗?上面,它显示两条消息被添加到notprocessedqueue,但只有processedqueue 显示消息计数(并且显示计数为 1,尽管您正在添加两条消息)。我确定这是一个复制粘贴错误,但这对于任何类型的帮助都非常重要...帮助。

标签: c# azure queue


【解决方案1】:

它终于成功了,我所做的是格式化存储我的解决方案的虚拟硬盘驱动器,然后我在azure管理门户中单击“恢复为默认值”,然后我重新启动计算机并重新部署了我的解决方案。

现在它的工作就像一个魅力,显然工人角色不知何故被窃听了。

【讨论】:

    猜你喜欢
    • 2015-09-27
    • 1970-01-01
    • 1970-01-01
    • 2014-02-02
    • 1970-01-01
    • 2015-12-13
    • 2022-01-23
    • 2021-06-13
    • 2021-04-14
    相关资源
    最近更新 更多