Azure的服务总线队列PeekBatch锁定? [英] Azure service bus queue PeekBatch locking?

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

问题描述

我现在用的是 PeekBatch(小于messageCount>)在 QueueClient (Windows Azure的服务总线包方法版本2.1.2.0)。

I am using the PeekBatch(<messageCount>) method on the QueueClient (Windows Azure Service Bus package version 2.1.2.0).

它正常工作的第一次,并返回该存在于我的队列我的单个消息,但后续调用返回什么。五分钟后,呼叫将然后再次返回该消息。

It works fine the first time, and returns my single message that exists in my queue, but subsequent calls return nothing. After five minutes, the call will then return the message again.

五分钟的最大锁定时间 BrokeredMessage ,所以我想知道如果 PeekBatch 实际上是锁定那些消息像它的接收,即使不偷看应该锁定,据我所知。

Five minutes is the maximum lock time on a BrokeredMessage, so I am wondering if PeekBatch is actually locking those messages like it does on a receive, even though peeking should not lock, as far as I know.

我想建立一个MVC视图能够看到什么是真正坐在我的队列中,但在路上这一块越来越。任何人都可以提供这方面的任何指导?

I am trying to build an MVC view to be able to see what is actually sitting in my queue, but this one is getting in the way. Can anyone provide any guidance on this?

更新:这似乎只使用静态属性来发生的事情,当我缓存我 QueueClient 。如果我创建 QueueClient 新鲜每一次,在 PeekBatch 按预期工作。我仍然不知道为什么重用 QueueClient 导致此。 微软似乎建议重用 QueueClient 虽然,而不是每次都重新创建它,所以我仍然在这里的损失。

Update: This only seems to be happening when I cache my QueueClient using a static property. If I create the QueueClient fresh every time, the PeekBatch works as expected. I still have no idea why reusing a QueueClient causes this. Microsoft seems to recommend reusing the QueueClient though, instead of recreating it every time, so I am still at a loss here.

推荐答案

该QueueClient正在有所帮助。在皮克方法(PEEK和PeekBatch),你可以简单地给他们打电话,或者你可以给一个特定的序列号一定顺序号后检索特定的消息。如果你简单地调用皮克,或在您的案件PeekBatch,没有一个序列号,然后它将检索的第一个消息,或消息,在队列中。一旦返回的消息的QueueClient跟踪它拉到最后一个序列号。偷看每次后续调用将获取队列中的下一条消息。我们的想法是,你是浏览消息每一次不只是感兴趣的第一条消息在队列中。

The QueueClient is being somewhat helpful. In the Peek methods (Peek and PeekBatch) you can simply call them, or you can give a specific sequence number to retrieve a specific message after a certain sequence number. If you simply call Peek, or in your case PeekBatch, without a sequence number then it will retrieve the very first message, or messages, in the queue. Once the message is returned the QueueClient keeps track of the last sequence number it pulled. Each subsequent call to Peek will fetch the next message in the queue. The idea is that you are "browsing" the messages and not just interested in the first message on the queue every time.

所以,如果你是在一个循环中,并呼吁偷看,直到它没有回报你将基本上都在队列浏览所有消息的消息。

So, if you were in a loop and called peek repeatedly until it didn't return a message you would essentially have browsed all message in the queue.

由于您没有QueueClient是要记住的最后一组它得到一个序列号呼叫PeekBatch,则下一次调用实际上会尝试浏览最后一条消息后,获得下一集。这就是为什么当你重新创建QueueClient似乎复位。它似乎5分钟后在它自己的重置的原因似乎很奇怪,但它也许只是经过一些点被拴在队列中的超时操作清理浏览值。届时序列号将是pretty遥远无论如何,如果它是一个繁忙的队列中。

Since you are calling PeekBatch without a sequence number the QueueClient is remembering the last set it got, then the next call would actually try to get the next set after the last message it browsed. This is why when you recreate the QueueClient it seems to reset. The reason it seemed to reset on it's own after 5 minutes seems odd, but it maybe just cleaning out the browsing values after some point that is tied to the Timeout operation on the queue. By then the sequence number would be pretty far off anyway if it was a busy queue.

如果你需要真的只有看的第一个消息,然后调用偷看只有一次。它只会返回第一个消息。如果您需要每次都不断拉第一条消息做了皮克(0)。如果你想先说10封邮件,每次然后调用PeekBatch(0,10);这将是像说给我说有一个大于0的序列号前十名的消息。

If you need to really only look at the very first message then call peek only once. It will only return the first message. If you need to continually pull the first message every time do a Peek(0). If you want the first say 10 messages every time then call PeekBatch(0, 10); that will be like saying give me the first ten messages that have a sequence number greater than 0.

重用QueueClient的指导声。它做的各种信息和事物缓存。你不希望每次都重新创建它。

The guidance to reuse the QueueClient is sound. It's doing all sorts of caching of information and things. You don't want to have to recreate it each time.

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

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