[英]Does Peek() method in PeekLock mode lock a Service bus message?
I know we can use Receive() method on PeekLock mode, to Lock the message, process it and finally Complete() it.我知道我们可以在 PeekLock 模式下使用 Receive() 方法来锁定消息,处理它,最后完成()它。 But, how does Peek() method work on PeekLock mode?
但是,Peek() 方法如何在 PeekLock 模式下工作? Does it lock the message?
它会锁定消息吗?
var client = messagingFactory.CreateQueueClient("entity", ReceiveMode.PeekLock);
BrokeredMessage = client.Peek();
Also, as a second question, I know we can repeatedly call the Peek() to peek all the Active end messages.另外,作为第二个问题,我知道我们可以重复调用 Peek() 来查看所有 Active 结束消息。 But, can Peek() method be used repeatedly to Peek all the dead lettered messages?
但是,可以重复使用 Peek() 方法来查看所有死信消息吗?
But, how does Peek() method work on PeekLock mode?
但是,Peek() 方法如何在 PeekLock 模式下工作? Does it lock the message?
它会锁定消息吗?
No, Peek()
does not lock the message regardless of the mode.不,无论模式如何,
Peek()
都不会锁定消息。 Mode is applicable to Receive()
only.模式仅适用于
Receive()
。 Not only that Peek()
can even return message which are locked by another receiver.不仅
Peek()
甚至可以返回被另一个接收者锁定的消息。
But, can Peek() method be used repeatedly to Peek all the dead lettered messages?
但是,可以重复使用 Peek() 方法来查看所有死信消息吗?
Yes, deadlettered messages resides in another special queue.是的,死信消息驻留在另一个特殊队列中。 You can
Peek()
from it just like a normal queue.您可以像普通队列一样从中
Peek()
。
Also to improve throughput, you can use PeekBatch
instead of Peek
.同样为了提高吞吐量,您可以使用
PeekBatch
而不是Peek
。
In summary, Peek
is the API for message browsing/diagnostics purpose.总之,
Peek
是用于消息浏览/诊断目的的 API。 You may want to give the official documentation a quick read.您可能想快速阅读官方文档。
Note: The peek operation on a non-partitioned entity always returns the oldest message, but not on a partitioned entity.注意:对未分区实体的查看操作始终返回最旧的消息,但不会在分区实体上返回。 Instead, it returns the oldest message in one of the partitions whose message broker responded first.
相反,它返回消息代理首先响应的分区之一中最旧的消息。 There is no guarantee that the returned message is the oldest one across all partitions.
无法保证返回的消息是所有分区中最旧的消息。
Peek
does not lock the message. Peek
不会锁定消息。 In fact, Peek doesn't even know any detail about the lock.事实上,Peek 甚至不知道关于锁的任何细节。 This is what the docs say:
这是文档所说的:
Peek also returns messages that were locked and are currently being processed by other receivers.
Peek 还返回已锁定且当前正在由其他接收器处理的消息。 However, because Peek returns a disconnected snapshot, the lock state of a message can't be observed on peeked messages.
但是,由于 Peek 返回断开连接的快照,因此无法在被偷看的消息上观察消息的锁定状态。
You can check this by accessing the messages's lock property, such as LockedUntilUtc
.您可以通过访问消息的锁定属性来检查这一点,例如
LockedUntilUtc
。 This will return you an exception InvalidOperationException
.这将返回一个异常
InvalidOperationException
。
The answer for your second question is simply "Yes".你的第二个问题的答案是“是”。 You can browse messages both active messages and dead-letters.
您可以浏览活动消息和死信消息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.