Question

What is the difference between Receive and Peek in the context of Azure Service Bus Topics?

Was it helpful?

Solution

  • Peek: This method enables you to view messages without locking or receiving them.
  • Receive: Can work in 2 modes: PeekLock (receives the message but keeps it peek-locked until the receiver abandons the message. The maximum timeout is 5 minutes before message expiration) and ReceiveAndDelete (deletes the message after it is received).

So this means you'll use the Peek when your goal is to look at the messages without actually consuming them (maybe you're building a "Queue browser", ... or your process needs to decided if it wants/can consume the message). And you'll use Receive when you're really planning to consume the message and do whatever you need to do with it.

Here is documentation on the PeakLock and ReceiveAndDelete values for ReceiveMode. Note that PeakLock is the default.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top