Azure Functions - Block processing of Azure Service Bus messages based on event type

I am new to azure and .net framework.I have an Azure Function (AF), that is triggered by Azure Service Bus based on the event type we have to process the message received for example event type: com.df.vc2.core.employee.add

if the event type is different from above it should not be processed

can this be done at configuration level? how this can be achieved

1 answer

  • answered 2021-11-29 07:46 Peter Bons

    You cannot do that using configuration, afaik there is no way of setting up some kind of exclusion list. However, you can do it using code. By default, when the function runs it automatically completes the message after successful processing. This is based upon the confuration settting AutoComplete as shown in the docs.

    If you set it to false you can then write the code in such a way that only messages you want to process in the function are completed. Other messages will be left untouched.

    If set to true, the trigger completes the message automatically if the function execution completes successfully, and abandons the message otherwise.

    When set to false, you are responsible for calling MessageReceiver methods to complete, abandon, or deadletter the message. If an exception is thrown (and none of the MessageReceiver methods are called), then the lock remains. Once the lock expires, the message is re-queued with the DeliveryCount incremented and the lock is automatically renewed.

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum