[英]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.java , RetryingMessageListenerAdapter.java
I have a few questions regarding this topic.关于这个话题,我有几个问题。
RetryingMessageListenerAdapter
's member stateful
as true through application.yml or ListenerContainerCustomizer
?有没有办法通过 application.yml 或ListenerContainerCustomizer
将RetryingMessageListenerAdapter
的成员stateful
设置为 true ?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 。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.