Azure / azure-sdk-for-java

This repository is for active development of the Azure SDK for Java. For consumers of the SDK we recommend visiting our public developer docs at https://docs.microsoft.com/java/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-java.
MIT License
2.3k stars 1.96k forks source link

[BUG] The retry options under the spring.cloud.azure.eventhubs.consumer are not applied correctly #35235

Open moarychan opened 1 year ago

moarychan commented 1 year ago

Describe the bug The retry functionality does not work, since the below configuration will not be applied correctly when using Spring Cloud Azure Stream Binder Event Hub.

spring.cloud.azure.eventhubs.consumer.retry.mode=exponential
spring.cloud.azure.eventhubs.consumer.retry.try-timeout=2
spring.cloud.azure.eventhubs.consumer.retry.exponential.base-delay=PT1S
spring.cloud.azure.eventhubs.consumer.retry.exponential.max-delay=PT3S
spring.cloud.azure.eventhubs.consumer.retry.exponential.max-retries=3

Exception or Stack Trace N/A

To Reproduce

spring:
  cloud:
    azure:
      eventhubs:
        consumer:
          retry:
            mode: exponential
            try-timeout: 2
            exponential:
              base-delay: PT1S
              max-delay: PT3S
              max-retries: 3

Code Snippet N/A

Expected behavior The retry options should only be taken for the consumer client, maybe all Azure SDK client, and the documentation should be synced as well.

Screenshots N/A

Setup (please complete the following information):

Additional context The same issues may exist for client options and proxy options, as well as the Service Bus side.

Information Checklist Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report

moarychan commented 1 year ago

A workaround is to move the retry options to spring.cloud.azure.eventhubs, such as below configuration:

spring:
  cloud:
    azure:
      eventhubs:
        retry:
          mode: exponential
          try-timeout: PT2S
          exponential:
            base-delay: PT1S
            max-delay: PT3S
            max-retries: 3
moarychan commented 1 year ago

Service Bus also has this problem.

vprudnikov commented 1 month ago

Hi :)

Any input on this?

I tried to configure a retry policy for my application, and the following configuration doesn't get applied:

spring:
  cloud:
    azure:
      retry:
        exponential:
          max-retries: 3
          base-delay: PT1S
          max-delay: PT10S
        mode: exponential
      servicebus:
        namespace: ${AZURE_SERVICEBUS_NAMESPACE}
        retry:
          exponential:
            max-retries: 3
            base-delay: PT1S
            max-delay: PT10S
          mode: exponential
    stream:
      bindings:
        consumeDocumentChange-in-0:
          destination: documents
    function:
      definition: consumeDocumentChange;

The message is simply retried 10 times in a row.

Thank you!

pom.xml:

        <spring-cloud.version>2023.0.3</spring-cloud.version>
        <spring-cloud-azure-dependencies>5.14.0</spring-cloud-azure-dependencies>

...

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>${spring-cloud.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>com.azure.spring</groupId>
                <artifactId>spring-cloud-azure-dependencies</artifactId>
                <version>${spring-cloud-azure-dependencies}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
...

        <dependency>
            <groupId>com.azure.spring</groupId>
            <artifactId>spring-cloud-azure-stream-binder-servicebus</artifactId>
        </dependency>

...