Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I configure azure function to peek and read message in service bus queue but not delete it?

Per Azure Functions Service Bus bindings:

Trigger behavior

...

PeekLock behavior - The Functions runtime receives a message in PeekLock mode and calls Complete on the message if the function finishes successfully, or calls Abandon if the function fails. If the function runs longer than the PeekLock timeout, the lock is automatically renewed.

I am assuming that when azure function calls Complete on the message, it will be removed from the queue.

What should I do in my function if I want my function to spy on the message but never delete it?

like image 234
Raghu Avatar asked Mar 23 '17 03:03

Raghu


People also ask

How do you peek a message on Azure Service Bus?

To peek into Dead-lettered messages of a queue or subscription, the peek operation should be run on the dead letter queue associated with the queue or subscription. For more information, see accessing dead letter queues.

How do I read messages from Azure Service Bus queue?

Overview of application Create Azure Service Bus Queue using Azure Portal. Create HTTP trigger Azure Function to send the message into Queue. Create a Service Bus Queue trigger Azure function to read a message from Queue.

What is peek lock in Azure Service Bus?

PeekLock. The peek-lock mode tells the broker that the receiving client wants to settle received messages explicitly. The message is made available for the receiver to process, while held under an exclusive lock in the service so that other, competing receivers can't see it.


1 Answers

Unsuccessful processing of a message resulting in function throwing an exception or an explicit abandon operation on the message will not complete the message.

Saying that, I see a problem with this approach. You're not truly "spying" on the messages, but actively processing those. Which means a given message will be re-delivered and eventually end up in the dead letter queue. If you want to spy, you should peek at the messages, but Azure Service Bus trigger doesn't do that.

If you need a wiretap implementation, it's probably not a bad idea to use a topic and have a 2 subscriptions, one to consume the messages and another to duplicate all the messages for your wiretap function (that perhaps does some sort of analysis or logging). Without understanding the full scope of what you're doing, hard to provide an answer.

like image 131
Sean Feldman Avatar answered Oct 02 '22 01:10

Sean Feldman