1

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.

Renu Saini
  • 19
  • 1
  • 3
  • 1
    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 Oct 23 '18 at 22:58
  • 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 Oct 24 '18 at 08:54
  • Do you control the Function that is picking up messages and invokes 3rd party? – Sean Feldman Oct 25 '18 at 03:39
  • @SeanFeldman we have control over the function which process the messages in queue. – Renu Saini Oct 29 '18 at 14:28
  • In that case, it seems disabling Azure Function would be a suitable approach. I'll add an answer. – Sean Feldman Oct 29 '18 at 14:39
  • https://stackoverflow.com/questions/75280748/control-azure-service-bus-consumer-to-start-or-stop-listening-from-the-topic-in Can you give answer to this question ? It is similar to this question. – Kush Patel Jan 30 '23 at 07:00

4 Answers4

3

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

Service Bus Suspension States

renjuwm
  • 81
  • 6
  • https://stackoverflow.com/questions/75280748/control-azure-service-bus-consumer-to-start-or-stop-listening-from-the-topic-in Can you give answer to this question ? It is similar to this question. – Kush Patel Jan 30 '23 at 07:00
2

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.

Sean Feldman
  • 23,443
  • 7
  • 55
  • 80
  • in order to do that somebody have to monitor the third party API and manually stop the azure function we want to handle this scenario programmatic , isn't there a way Azure function disable the queue temporarily till the third party comes back to life and enable again? – Renu Saini Oct 31 '18 at 09:39
  • 1
    Disabling queue or Function will require an additional component with logic. Either way, it's not "sit and watch and then action", but automated monitoring/probing. With 3rd party it could be a ping. Or, you could set up monitoring of a queue size increase/decrease over a period of time to invoke another function that would enable/disable your Function or Queue. – Sean Feldman Oct 31 '18 at 13:06
2

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://learn.microsoft.com/en-us/azure/service-bus-messaging/service-bus-queues-topics-subscriptions

SwissCoder
  • 2,514
  • 4
  • 28
  • 40
1

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.

Joey Cai
  • 18,968
  • 1
  • 20
  • 30
  • we want to disable the queue pragmatically as soon our third party API is down we disable the queue and enable it as soon its up again. – Renu Saini Oct 29 '18 at 14:31