简体   繁体   English

如何使用 spring-cloud-stream-binder-kafka 和 RetryTemplate 启用状态重试?

[英]How to enable Stateful Retry using spring-cloud-stream-binder-kafka and RetryTemplate?

I am wondering if there is a way to enable Stateful RetryTemplate using spring-cloud-stream-binder-kafka.我想知道是否有一种方法可以使用 spring-cloud-stream-binder-kafka 启用 Stateful RetryTemplate。

I noticed that there is a constructor我注意到有一个构造函数

RetryingMessageListenerAdapter(MessageListener<K, V> messageListener, RetryTemplate retryTemplate, RecoveryCallback<? extends Object> recoveryCallback, boolean stateful)

Debugging through this code, I noticed that boolean value false is passed into stateful parameter using spring-cloud-stream-binder-kafka.通过这段代码调试,我注意到使用 spring-cloud-stream-binder-kafka 将 boolean 值false传递给stateful参数。

Related links: KafkaMessageDrivenChannelAdapter.java , RetryingMessageListenerAdapter.java相关链接: KafkaMessageDrivenChannelAdapter.javaRetryingMessageListenerAdapter.java

I have a few questions regarding this topic.关于这个话题,我有几个问题。

  1. Is there a way to set RetryingMessageListenerAdapter 's member stateful as true through application.yml or ListenerContainerCustomizer ?有没有办法通过 application.yml 或ListenerContainerCustomizerRetryingMessageListenerAdapter的成员stateful设置为 true ?
  2. Is there a way to disable RetryTemplate using spring-cloud-stream-binder-kafka?有没有办法使用 spring-cloud-stream-binder-kafka 禁用RetryTemplate I think the closest I found was to override max-attempts to 1 in my @StreamRetryTemplate .我认为我发现的最接近的是在我的@StreamRetryTemplate max-attempts覆盖为 1 。
  3. If I am using SeekToCurrentErrorHandler provided by spring-kafka, is there any benefit or reason why I should set stateful as true since SeekToCurrentErrorHandler is already a stateful error handling mechanism?如果我使用的是 spring-kafka 提供的SeekToCurrentErrorHandler ,由于SeekToCurrentErrorHandler已经是一个有状态的错误处理机制,我应该将stateful设置为 true 有什么好处或原因吗?

Please let me know.请告诉我。

Stateful retry is no longer needed now that the SeekToCurrentErrorHandler has retry and backoff capabilities.由于SeekToCurrentErrorHandler具有重试和退避功能,因此不再需要状态重试。

Yes, to disable retry in the binder, set maxAttempts=1 and configure the STCEH appropriately.是的,要在活页夹中禁用重试,请设置maxAttempts=1并适当配置 STCEH。

暂无
暂无

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

相关问题 使用 spring-cloud-stream-binder-kafka 将 GlobalStateStore 绑定到处理器中 - Binding GlobalStateStore into Processor with spring-cloud-stream-binder-kafka spring-cloud-stream-binder-kafka 和 spring-cloud-starter-stream-kafka 的区别 - Difference between spring-cloud-stream-binder-kafka and spring-cloud-starter-stream-kafka spring-cloud-stream-binder-kafka - 无法使用 ssl 配置创建多个 kafka 活页夹 - spring-cloud-stream-binder-kafka - Unable to create multiple kafka binders with ssl configuration spring cloud stream kafka binder允许/拒绝针对特定异常重试吗? - Can spring cloud stream kafka binder allow/deny retry for specific exceptions? 空指针:带有活页夹 kafka 的 Spring Cloud 流 - Null pointer: Spring cloud stream with binder kafka Spring 使用 Spring 云启动应用程序 Stream Kafka Binder + Kafka Streams Binder 不工作 - 生产者不发送消息 - Spring Boot application using the Spring Cloud Stream Kafka Binder + Kafka Streams Binder not working - Producer doesn't send messages How to create multi output stream from single input stream with Spring Cloud Kafka stream binder? - How to create multi output stream from single input stream with Spring Cloud Kafka stream binder? Spring Cloud kafka流消费者重试机制 - Spring cloud kafka stream consumer retry mechanism 使用 Spring Cloud Stream Kafka Binder 批量消费 Kafka 消息及其密钥 - Consuming Kafka messages with its key in batches using Spring Cloud Stream Kafka Binder 使用 Kafka Binder 在 Spring 云中打印 JsonObject - Printing JsonObject in Spring cloud using Kafka Binder
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM