Reputation: 317
Does anyone knows the difference between the receive and peek options in azure service bus?
var client = new MessageReceiver("ServiceBusConnectionString", "Queue");
// difference between this one:
var peekResults = await client.PeekAsync(100);
// and this one
var receiveResults = await client.ReceiveAsync(100);
I see I can get the same results, but I want to know which one should I use and why? so internally what would be the difference?
Upvotes: 2
Views: 2660
Reputation: 26057
Peek will fetch messages w/o increasing delivery counter. It's a way to "preview" messages w/o removing from the queue.
Receive will increase the delivery counter. When received in ReceiveAndDelete
mode, messages will be gone from the queue. With PeekLock
mode messages will remain on the queue unless MaxDeliveryCount
was exceeded and they will be dead-lettered.
Upvotes: 8