I am using spring cloud streams with kafka bindings. The consumer is configured using spring.cloud.stream.kafka.bindings.function configuration and DLQ is enabled.
spring.cloud.stream.kafka.bindings.consumeTest-in-0:
consumer:
batch-mode: false
ackEachRecord: true
dlqName: test.file.error
enableDlq: true
dlqProducerProperties.configuration.key.serializer: org.apache.kafka.common.serialization.StringSerializer
dlqProducerProperties.configuration.value.serializer: org.apache.kafka.common.serialization.StringSerializer
maxAttempts: 5
backOffInitialInterval: 5000
backOffMaxInterval: 5000
When, I consume a message from a topic, and an exception occurs, I see that it retries 3 times, and sends the message to DLQ. I have configured with maxAttempts to 5 but I am unable to override the default value of 3.
I am using spring kafka (2.7.8) and spring cloud (2020.0.4). How can I override the retry attempts and backOff interval params?
I noticed if I add the params at default consumer level (as below), they are picked, but not at function bindings level:
spring.cloud.stream.default.consumer:
maxAttempts: 5
defaultRetryable: true
backOffInitialInterval: 5000
backOffMaxInterval: 5000
backOffMultiplier: 1
Thanks
CodePudding user response:
Put it under spring.cloud.stream.bindings.consumeTest-in-0.consumer.maxAttempts=5
instead of your spring.cloud.stream.kafka.bindings.consumeTest-in-0.consumer.maxAttempts=5.
See here: Common Properties