none
How retry works in Azure Service Bus Java RRS feed

  • Question

  • Hello Experts,

              I'm new to service bus, I'm curious about RetryPolicy and how it works, as per the documentation, retry had happened automatically for transient exceptions(MessagingExcepitons, ServerBusy), and the default retry count is 3, but we can set out custom retry policy using RetryExponential class. I want to see the logs does the RetryPolicy did actually trying  to connect or not when exception ouccres. How can I check this, how to replicate  MessagingExcepitons, ServerBusy exceptions , so that I can see the logs. I'm using azure service bus java sdk.

    Can any one help me to understand this. Thanks in advance

     


    Saturday, May 25, 2019 5:09 PM

All replies

  • The Java SDK is open source and looking for retryPolicy in these files shows how the underlying implementation uses it

    For example, here's the flow for CoreMessageSender when an error is thrown

    1. When an error occurs and if its a ServiceBusException, a retry is scheduled - See line
    2. After waiting, it ensures the link is still open and increments the retry count - See line
    3. This continues and on successful completion it resets the count - See line

    As for logging, the Java SDK uses SLF4J and you can see the required logs with a line like this in your code

    import org.apache.log4j.Level;
    import org.apache.log4j.Logger;
    
    Logger.getLogger("com.microsoft.azure.servicebus").setLevel(Level.WARN);

    Tuesday, May 28, 2019 11:21 AM
    Moderator