brokeredmessage微软服务总线队列ReceiveBa

brokeredmessage微软服务总线队列ReceiveBa

本文介绍了brokeredmessage微软服务总线队列ReceiveBatch没有获得所有死信消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我测试了死信队列与微软服务总线的项目。我送26消息(代表字母)和我使用一个程序,接到消息时,随机把他们有的在死信队列。消息总是从死信队列偷看模式阅读,所以一旦他们到达那里,他们呆在那里。跑了几次后,所有26个邮件将在死信队列,并始终保持在那里。

I am testing a project with a dead letter queue with Microsoft Service Bus. I send 26 messages (representing the alphabet) and I use a program that when receiving the messages, randomly puts some of them in a dead letter queue. The messages are always read in peek mode from the dead letter queue, so once they reach there they stay there. After running a few times, all 26 messages will be in the dead letter queue, and always remain there.

然而,阅读它们的时候,有时只有少数(如6 。)阅读,有时所有26

However, when reading them, sometimes only a few (e.g. 6) are read, sometimes all 26.

我用命令:

const int maxToRead = 200; // It seems one wants to set this higher than
                          // the anticipated load, obtaining only some back
IEnumerable<BrokeredMessage> dlIE =
            deadletterSubscriptionClient.ReceiveBatch(maxToRead);

有是具有超时ReceiveBatch过载,但这并没有帮助,而且只有proably增加了复杂性。

There is an overload of ReceiveBatch which has a timeout, but this doesn't help, and proably only adds to the complexity.

为什么它不获取所有信息26每一次,因为它是在窥视模式下使用,消息呆在那里。

Why doesn't it obtain all 26 messages every time, since it is used in "peek" mode and the messages stay there.

我可以用服务总线资源管理器,以实际验证所有的消息都在死信队列中,并留在那里。

I can use "Service Bus Explorer" to actually verify that all messages are in the deadletter queue and remain there.

这主要是测试的例子,但人们希望ReceiveBatch将在确定模式下工作,而不是在一个非常(坏)随机的方式...

This is mostly a testing example, but one would hope that "ReceiveBatch" would work in deterministic mode and not in a very (bad) random manner...

推荐答案

这仅仅是一个局部的答案或解决方法;以下代码可靠地获取所有元件,但不使用ReceiveBatch;注意,据我可以看出,皮克(i)对一开始的索引操作。另外:这取决于服务器的一台正在运行的,如果你被消息拉动充电,这可能(也可能不会)更昂贵,所以在您自己的风险是:

This is only a partial-answer or work-around; the following code reliably gets all elements, but doesn't use the "ReceiveBatch"; note, as far as I can discern, Peek(i) operates on a one-based index. Also: depending on which server one is running on, if you are charged by the message pull, this may (or may not) be more expensive, so use at your own risk:

            List<BrokeredMessage> dlIE = new List<BrokeredMessage>();

            BrokeredMessage potentialMessage = null;
            int loopCount = 1;
            while ((potentialMessage = deadletterSubscriptionClient.Peek(loopCount)) != null)
            {
                dlIE.Add(potentialMessage);
                loopCount++;
            }

这篇关于brokeredmessage微软服务总线队列ReceiveBatch没有获得所有死信消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-06 03:54