I have azure function which trigger when we ave new message into service bus topic.
In azure function I checked the customer api is available or not
by calling it and checking its status code
.
If status code is 200 I need to process the message else put this message into dead-letter and after some interval when customer api is available then process all dead letter message also.
public static class Function1
{
[FunctionName("Function1")]
public static void Run([ServiceBusTrigger("customer-order", "customer-order", Connection = "")]string mySbMsg, ILogger log)
{
// 1.call customer api to check it is available or not
// 2.if it is up and running then process the message else put message into dead-letter
// and after some interval when customer ai is available process dead-letter messages
log.LogInformation($"C# ServiceBus topic trigger function processed message: {mySbMsg}");
}
}
I can able to invoke customer api
using HTTPClient and process message also.
but how to put message into dead-letter and How to execute dead-letter after some interval when customer api is available ?
Proposed Flow Will be
in azure function app which will trigger if new message is there into.
topic start step - Check api is available or down if api is available
process the current message if api is down then do not process
message here we have two choices
1a.put current message into dead letter 1b.put current message back into main but if we do this then again function app will trigger as its new message trigger based and start step will continue.