0
votes

We are using Azure Service bus Message Queue to process some action which are performed on third party API, issue we are having the third party API is down , what we want to do is suspend the queue temporarily so we can hold message till the third party service start working again, or is there another way we can retain the messages so we can reprocess them again.

4
The description is confusing. The whole point of having a queue is to decouple and load level. If 3rd party is having a trouble, messages will stay in the queue, you don't have to do a thing. You should add more details to what the problem is if that's not the case.Sean Feldman
Issues is azure function pick up the message and start processing it but third party api is down so message is consumed but didn't get the result we want effectively we should send same message again when third part api is up again.Renu Saini
Do you control the Function that is picking up messages and invokes 3rd party?Sean Feldman
@SeanFeldman we have control over the function which process the messages in queue.Renu Saini
In that case, it seems disabling Azure Function would be a suitable approach. I'll add an answer.Sean Feldman

4 Answers

2
votes

Based on the comments, it's Azure Function that is invoking 3rd party API that could fail. In this scenario, disabling Azure Function could be a simpler approach - no processing attempts, no message retries, no changes to your Azure Service Bus namespace/entities. Once you're confident you can re-enable Azure Function, messages will be processed again.

2
votes

You can update the queue state to ReceiveDisabled. This will help to stop the Azure Function Trigger.

Service Bus Suspension States

1
votes

Queues, topics, and subscriptions can be temporarily suspended. Suspension puts the entity into a disabled state in which all messages are maintained in storage. However, messages cannot be removed or added, and the respective protocol operations yield errors.

A suspension or reactivation can be performed either by the user or by the system. The system only suspends entities due to grave administrative reasons such as hitting the subscription spending limit. System-disabled entities cannot be reactivated by the user, but are restored when the cause of the suspension has been addressed.

In the portal, the Properties section for the respective entity enables changing the state; the following screen shot shows the toggle for a queue: enter image description here Note:The portal only permits completely disabling queues(The queue is suspended).

For more details, you could follow to this article.

1
votes

Use the PeekLock Mode on the Service Bus Queue.

This way you can already get the message and start processing it, before it is removed from the queue. In case the 3rd Party is unavailable you can call AbandonAsync, which puts the message back in the queue. In case the 3rd party stays offline for too long, your messages should end up in some deadletter queue, from where you can move the messages back to the original queue where they can be processed again.

More details: https://docs.microsoft.com/en-us/azure/service-bus-messaging/service-bus-queues-topics-subscriptions