- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
以下是配置
@Bean
@Autowired
public ConcurrentKafkaListenerContainerFactory<byte[], byte[]> kafkaListContFactory(@Qualifier("retryTemplate") RetryTemplate retryTemplate, @Qualifier("batchErrorHandler") ErrorHandler errorHandler, @Qualifier("batchErrorHandler") BatchErrorHandler batchErrorHandler) {
ConcurrentKafkaListenerContainerFactory factory = new ConcurrentKafkaListenerContainerFactory();
factory.setConsumerFactory(consumerFactory());
factory.getContainerProperties().setAckOnError(false);
factory.getContainerProperties().setAckMode(ContainerProperties.AckMode.MANUAL_IMMEDIATE);
factory.setErrorHandler(errorHandler);
factory.getContainerProperties().setAckOnError(false);
factory.setStatefulRetry(true);
factory.setRetryTemplate(retryTemplate);
}
**Retry config**
@Bean("retryTemplate")
public RetryTemplate retryTemplate() {
final ExponentialBackOffPolicy backOffPolicy = new ExponentialBackOffPolicy();
backOffPolicy.setInitialInterval(delay);
backOffPolicy.setMultiplier(multiplier);
backOffPolicy.setMaxInterval(20000);
final RetryTemplate template = new RetryTemplate();
template.setRetryPolicy(new AlwaysRetryPolicy());
template.setBackOffPolicy(backOffPolicy);
return template;
}
SeekToCurrentErrorHandler config
I do not want to recover and try to retry till it succeeds so I have given maxAttempts to -1
@Bean("errorHandler")
public ErrorHandler errorHandler() {
final ExponentialBackOffPolicy backOffPolicy = new ExponentialBackOffPolicy();
SeekToCurrentErrorHandler handler = new SeekToCurrentErrorHandler((r, t) -> {
if (t != null && (t instanceof RetryServiceException || t.getCause() instanceof RetryServiceException)) {
logger.error("SeekToCurrentErrorHandler recoverer failure", t.getMessage());
throw new RetryServiceException("SeekToCurrentErrorHandler recoverer failure");
}
}, -1);
return handler;
}
最后,当没有发生异常时,我会在 @KafkaListener 方法中进行确认。
我的问题是,如果我将 -1 配置为最大尝试次数,并且我的错误处理程序将负责重试,我是否需要 retryTemplate?但重试不会发生无限次,问题是如果我获取批处理记录,如果其中一条消息在轮询中失败,则我正在处理相同的消息,所有消息都将被重新处理。
我需要使用batchErrorHandler并实现指数退避策略,以便重试是有状态的,并且应该避免重新处理相同的成功消息。谁能帮忙解决上述问题。
我需要避免通过错误使用max.poll.interval.ms来重新平衡分区
最佳答案
您需要使用Stateful Retry避免重新平衡;但是,对于现代版本,您根本不需要监听器级别重试,因为您现在可以在错误处理程序级别执行重试并退出。
使用构造函数接受 BackOff
并删除容器重试模板。
/**
* Construct an instance with the provided recoverer which will be called after
* the backOff returns STOP for a topic/partition/offset.
* @param recoverer the recoverer; if null, the default (logging) recoverer is used.
* @param backOff the {@link BackOff}.
* @since 2.3
*/
public SeekToCurrentErrorHandler(@Nullable BiConsumer<ConsumerRecord<?, ?>, Exception> recoverer, BackOff backOff) {
I need to use batchErrorHandler and implement a exponential backoff strategy so that retry will be stateful and reprocessing of same success messages should be avoided. Could anyone help with the above issue.
框架无法帮助批处理监听器,因为它不知道失败发生在何处(在批处理中)。
关于java - 使用 Spring-Kafka-2.3.0 及更高版本使用主题中的消息并以指数退避重试,直到成功为止,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59819604/
如何根据 e(公钥)、d(私钥)和模数计算 p 和 q 参数? 我手边有 BigInteger 键,我可以将粘贴复制到代码中。一个公钥、一个私钥和一个模数。 我需要据此计算 RSA 参数 p 和 q。
如何在 JavaScript 中计算指数? 比如你会怎么做 12^2? 最佳答案 Math.pow() : js> Math.pow(12, 2) 144 关于JavaScript 指数,我们在Sta
也许是时候喝一杯咖啡了,但我看到了一个我没想到会看到的奇怪问题。 我正在阅读 JavaScript The Good Parts,在语法部分我看到以下内容: If a number literal h
我正在使用带有 eclipse link 2.3 &Derby db 的实体管理器 JPA,并且我有包含 10 个实体的模型,对于每个实体,我需要存储 1000 条记录,此过程大约需要 70 秒。我已
我习惯了制作 iPhone 应用程序,但现在我需要制作 Mac 应用程序。因此我必须切换到 Cocoa 框架。 有没有类似于 Cocoa 中的 array.index(of: ) 的东西? iOS 示
我正在尝试在控制台中打印文件名“xyz.0.html”。它吐出一个错误 "substring not found" 目录中的文件: xyz.0.html xyz.1.html xyz.2.html p
我需要计算 h-index来 self 存储在树中的出版物列表。 我所做的是按递减顺序遍历树,获取引用位置列表 看起来像: line 1 10 line 2 5 line 3 4 line 4 0 我
有没有一种更简单的方法将幂符号/指数符号转换为其等价数字(即从 ⁸ 到 8),而不仅仅是一堆 replace是吗? 编辑:谢谢大家的解决方案! 最佳答案 您可以创建一个正则表达式并执行一次 repla
我编写这段代码是为了查找指数 b 的最后一位数字,但 SPOJ 说它是错误的。我尝试了几乎所有的测试用例,但找不到错误。问题:http://www.spoj.com/problems/LASTDIG/
我对 CSS 中的 z-index 有疑问。 代码: div.banniere{ background-image:url('../img/banniere.png'); backgr
我有一个弹出的“对话框”小部件,其 z-index 为 100。当我创建另一个弹出窗口( float div)时,它出现在对话框小部件下方,因为我没有明确设置 z -新弹出窗口的索引。 结构最终看起来
我正在尝试从一篇学术论文中实现一个真相发现算法。它是一种流式算法,可以实时推断真相和源质量。如果有人有兴趣阅读本文,请在此处了解更多详细信息:http://dl.acm.org/citation.cf
这个问题在这里已经有了答案: Difference between Big-O and Little-O Notation (5 个答案) 关闭 8 年前。 直观上,nb = o(an)(o 是小哦
我在这里使用 sklearn 制作了一个决策树,在 SciKit learn DL 包下,即。 sklearn.tree.DecisionTreeClassifier().fit(x,y)。 如何在每
为了解释这一点,这基本上是一种将浮点向量数据缩小为 8 位或 16 位有符号或无符号整数的方法,该整数具有单个公共(public)无符号指数(最常见的是 bs16 以 11 为常用指数的精度)。 我不
是否可以在 Algolia 中“加入”索引?获得合并结果? 例如: 如果我有两个索引:一个用于“用户”,一个用于“事件”。每个用户都有 id 和 name 属性。每个事件都有 date 和 userI
有人可以提供一个关于如何在 pytorch 中为语义分割计算 IoU(交集对联合)的玩具示例吗? 最佳答案 我在某处找到了它并为我改编了它。如果我能再次找到它,我会发布链接。抱歉,如果这是重复的。 这
我正在将 NativeBase 与指数一起使用。标题位于手机的状态栏下方。您可以在 NativeBase 中看到这一点指数发布的演示。 有没有人解决这个问题? 最佳答案 由于此问题仅在 Android
基本上,有20只羊为一组。当羊群发展到80只羊后,就不再需要有人看管了。每年 t 的羊数量 N 可以通过以下公式找到: N = 220/(1 + 10(0.83)^t) 该程序试图找出羊需要被监管多少
我正在尝试编写一个 SPARQL 查询,我想在其中过滤某些内容的平方,但我根本无法弄清楚如何计算数字的平方(x2)(当然,除了将其与自身相乘之外)。我猜想有一个名为 math:sqrt() 的平方根函
我是一名优秀的程序员,十分优秀!