Apache kafka Spring集成Kafka-使用SeektocurInterrorHandler处理异常
问题陈述:Apache kafka Spring集成Kafka-使用SeektocurInterrorHandler处理异常,apache-kafka,spring-integration,spring-kafka,Apache Kafka,Spring Integration,Spring Kafka,问题陈述: 在kafka中使用消息时需要处理异常 提交失败的偏移量 查找到下一个未处理的偏移量,以便下一次轮询从此偏移量开始 似乎所有这些都是作为Spring Kafka中SeekTocurInterrorHandler.java的一部分处理的 如何在Spring Integration Kafka中利用此功能 请帮忙 使用的版本: 弹簧集成卡夫卡-3.3.1 ApacheKafka的Spring-2.5.x @Bean(name ="kafkaConsumerFactory"
@Bean(name ="kafkaConsumerFactory")
public ConsumerFactory consumerFactory0(
HashMap<String, String> properties = new HashMap<>();
properties.put("bootstrap.servers", "kafkaServerl");
properties.put("key.deserializer", StringDeserializer.class);
properties.put("value.deserializer", StringDeserializer.class);
properties.put("auto.offset.reset", "earliest");
} return new DefaultKafkaConsumerFactoryo(properties); I
@Bean("customKafkalistenerContainer")
public ConcurrentMessagelistenerContainerCtring, AddAccountReqRes> customKafkaListenerContainer() (
ContainerProperties containerProps = new ContainerProperties("Topici");
containerProps.setGroupld("Groupldl");
return (ConcurrentMessagelistenerContainerCtring, CustomReqRes>) new ConcurrentMessageListenerContainer<>(
} kafkaConsumerFactory, containerProps);
IntegrationFlows.from(Kafka.messageDrivenChannelAdapter(customKafkalistenerContainer, KafkaMessageDrivenChannelAdapter.ListenerMode.record)
.errorChannel(errorChannel()))
.handle(transformationProcessor, "process")
.channel("someChannel")
.get();
@Bean(name=“kafkaConsumerFactory”)
公共ConsumerFactory consumerFactory0(
HashMap属性=新建HashMap();
properties.put(“bootstrap.servers”、“kafkaServerl”);
properties.put(“key.deserializer”,StringDeserializer.class);
properties.put(“value.deserializer”,StringDeserializer.class);
properties.put(“自动偏移、重置”、“最早”);
}返回新的DefaultKafka消费者工厂(属性);I
@Bean(“customKafkalistenerContainer”)
public ConcurrentMessageListenerContainerString,AddAccountReqRes>CustomKafkAlisterContainer()
ContainerProperties containerProps=新的ContainerProperties(“Topici”);
containerProps.setGroupld(“Groupldl”);
返回(ConcurrentMessageListenerContainerString,CustomReqRes>)新的ConcurrentMessageListenerContainer(
}卡夫卡消费工厂(集装箱公司);
IntegrationFlows.from(Kafka.messageDrivenChannelAdapter(自定义kafkalistenercontainer,KafkaMessageDrivenChannelAdapter.ListenerMode.record)
.errorChannel(errorChannel()))
.handle(transformationProcessor,“流程”)
.channel(“someChannel”)
.get();
spring integration kafka
在下面使用spring kafka,因此您只需使用错误处理程序配置适配器的容器
spring-integration-kafka
从5.4开始被移动到了spring-integration(以前是一个扩展)。因此,两个jar的当前版本都是5.4.2。spring-integration-kafka
在下面使用spring-kafka,所以您只需要使用错误处理程序配置适配器的容器
spring集成kafka
从5.4开始被移动到spring集成(以前是一个扩展)。因此,这两个JAR的当前版本都是5.4.2。感谢您的快速响应。我们不知道如何使用此适配器的容器处理kafka的异常。请您提供包含此代码段的url,以帮助我们。此外,我们目前无法移动到最新版本的spring integration。编辑t他提出了一个问题来显示您的spring integration配置bean,这样我们就可以告诉您需要更改什么。我猜不出您当前的配置。我刚刚添加了关于5.4的注释,以获取一般信息。5.3.x和3.3.1仍然受支持。嗨,Gary Russell,我在上面的问题中更新了配置。请您帮助进行通用配置在处理连接器流异常的同时,我们可以在spring integration flows中处理SeektocurInterrorHandler.java逻辑的功能。在您的CustomKafkAlisterContainer
@Bean
中,使用容器上的所需属性设置错误处理程序。感谢您的快速响应。缺少了解异常如何处理的功能d将使用此适配器的容器为kafka处理。请提供包含此代码段的url,以提供帮助。此外,我们目前无法移动到最新版本的spring integration。请编辑此问题以显示spring integration配置bean,以便我们可以告诉您需要更改什么。我猜不出答案t您当前的配置。我刚刚添加了关于5.4的注释,以获取一般信息。5.3.x和3.3.1仍然受支持。嗨,Gary Russell,我已经更新了上述问题中的配置。请您帮助我们在处理conne时处理spring集成流中的SeektocurInterrorHandler.java逻辑的通用功能ctor流异常。在您的customKafkaListenerContainer
@Bean
中,使用容器上所需的属性设置错误处理程序。