简体   繁体   English

PeekLock 模式下的 Peek() 方法是否锁定服务总线消息?

[英]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.

相关问题 如何使用REST Client在Azure Service Bus主题上窥视锁定消息而不接收和删除 - How to Peek-Lock Message and not Receive and Delete on Azure Service Bus Topic using REST Client Azure服务总线消息锁是否未续订? - Azure Service Bus message lock not being renewed? Azure 服务总线队列消息锁定在 UTC 午夜到期 - Azure Service Bus queue message lock expires at midnight UTC 如何处理不带锁定令牌的Azure服务总线代理消息? - How to process azure service bus brokered message without lock token? 如果在Azure Service Bus中消息接收模式为ReceiveAndDelete,则消息的TTL是多少? - Whats the TTL for a message if the message receiving mode is ReceiveAndDelete in Azure Service Bus? Azure Service Bus队列最大批量更新消息锁定以进行批处理 - Azure Service Bus Queue Maximum Renewal of Message Lock for Batch Processing 如何查看 Azure 服务总线队列中的所有消息? - How to peek all messages in Azure Service Bus queue? Peek 如何在启用分区的服务总线队列中工作? - How Peek works in a Partition enabled Service Bus Queue? 消息工作成功完成后,Azure Service Bus“提供的锁无效” - Azure Service Bus “The lock supplied is invalid” after message work successfully completed Azure服务总线消息删除 - Azure Service Bus message deleting
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM