0
votes

I have the following Http Triggered Azure Function to send data into the queue. But how can I see the behaviour that Azure Service Bus does not guarantee FIFO order?

I am using a peek-lock receiving behaviour. Assuming I have messages 1,2,3,4 in the queue. If my application failed when receiving message 1, how does Azure Function react due to its concurrency? Will there be another thread that reads message 2 while message 1 timeout?

        [FunctionName("ServiceBusFunction")]
        public static void Run([ServiceBusTrigger("testQueueDuplicateDetection")] string myQueueItem, ILogger log)
        {
            log.LogInformation($"C# ServiceBus queue trigger function processed message: {myQueueItem}");
        }

        [FunctionName("ServiceBusOutput")]
        [return: ServiceBus("testQueueDuplicateDetection")]
        public static string ServiceBusOutput([HttpTrigger] string input, ILogger log)
        {
            log.LogInformation($"C# function processed: {input}");
            return input;
        }

Thanks in advance!

1

1 Answers

0
votes

But how can I see the behaviour that Azure Service Bus does not guarantee FIFO order?

Azure Service Bus allows for a FIFO approach (First-In-First-Out), we cannot guarantee that messages are entered in the order we want them to be processed by a Subscriber process.

To do that, we would need to sacrifice the multi-threaded / multi-process (Fan-In) way of entering messages and instead adopt a single-Publisher approach. Similarly, on the message processing side we cannot guarantee a thread-safe approach to processing messages without adopting a single-Subscriber approach, thereby sacrificing the scalability benefits of the Fan-Out approach.

Each of these options, will diminish the rich features of the Azure Service Bus, reducing the power of a true Service Bus architecture.

You can refer this link for more information.

I have messages 1,2,3,4 in the queue. If my application failed when receiving message 1, how does Azure Function react due to its concurrency? Will there be another thread that reads message 2 while message 1 timeout?

Based on azure documentation, Functions runtime receives a message in peek-lock mode. It 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 as long as the function is running.