简体   繁体   English

使用 Spring Cloud 流 kafka 绑定消费者和启用 DLQ 覆盖重试尝试

[英]Override retry attempts with spring cloud stream kafka bindings consumer and DLQ enabled

I am using spring cloud streams with kafka bindings.我正在使用带有 kafka 绑定的 Spring Cloud 流。 The consumer is configured using spring.cloud.stream.kafka.bindings.function configuration and DLQ is enabled.使用 spring.cloud.stream.kafka.bindings.function 配置配置消费者并启用 DLQ。

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.当我从一个主题中消费一条消息,并发生异常时,我看到它重试了 3 次,并将消息发送到 DLQ。 I have configured with maxAttempts to 5 but I am unable to override the default value of 3.我已将 maxAttempts 配置为 5,但无法覆盖默认值 3。

I am using spring kafka (2.7.8) and spring cloud (2020.0.4).我正在使用 spring kafka (2.7.8) 和 spring cloud (2020.0.4)。 How can I override the retry attempts and backOff interval params?如何覆盖重试尝试和 backOff 间隔参数?

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谢谢

Put it under spring.cloud.stream.bindings.consumeTest-in-0.consumer.maxAttempts=5 instead of your spring.cloud.stream.把它放在spring.cloud.stream.bindings.consumeTest-in-0.consumer.maxAttempts=5而不是你的 spring.cloud.stream 下。 kafka .bindings.consumeTest-in-0.consumer.maxAttempts=5.卡夫卡.bindings.consumeTest合0.consumer.maxAttempts = 5。


See here: Common Properties请参阅此处: 通用属性

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM