An Azure service that provides a hybrid, multi-cloud management platform for APIs.
Improving Reliability When Publishing to Service Bus from APIM
I am currently publishing messages to Service Bus (SB) from APIM using the send-request policy.
The policy is configured with:
- Timeout: 3 seconds
- Retry count: 3
- Retry interval: 1 second
- First-fast-retry: enabled
Unfortunately, I cannot use the send-service-bus-message policy because we are running APIM Standard v2.
Our workload is approximately 130,000 requests per day, all of which are published to a Service Bus Standard namespace.
Occasionally, messages are not published successfully. In Service Bus metrics, these incidents appear as server errors, while APIM logs show request timeouts. From our observations, it seems that Service Bus sometimes takes longer than 3 seconds to respond, causing APIM to time out. However, during these incidents, Service Bus metrics generally do not indicate any throttling or capacity-related issues.
I am aware that the recommended retry interval for Service Bus is typically around 10 seconds, but our API must acknowledge incoming requests within 5 seconds, which limits our ability to increase timeouts or retry delays.
My main concern is reliability. I do not want to acknowledge a request before the message has been successfully published to Service Bus, as this could result in a lost request if the publish operation ultimately fails.
Given these constraints:
- What would be the recommended approach to improve reliability in this scenario?
- Is using an Azure Function as an intermediary publisher a better pattern, both from a durability and operational perspective?
- Would it provide more robust retry handling and reduce the risk of message loss compared to publishing directly from APIM via
send-request?
Any recommendations or best practices for handling this pattern would be appreciated.