我需要当前易于遵循的说明来从 XML 配置 spring 集成 kafka [英] I need current easy to follow instructions for configuring spring integration kafka from XML
问题描述
spring 集成 kafka 模型已经发生了足够的变化,因为它已经被处理和简化,现有的演示、手册和说明不再起作用.目前官方的demo都是围绕注解构建的,虽然很酷,但基本上不可读,不适合我的架构,作业与java代码分开部署和管理.
The spring integration kafka model has changed sufficiently as it has been worked on and simplified that the extant demos, manuals, and instructions don't work any more. The current official demos are all built around annotations, which are cool, but largely unreadable, and are not appropriate for my architecture in which the jobs are deployed and managed separately from the java code.
是否有当前 (2019) 教程,用于在 XML 中配置 spring 集成生产者和消费者?
Is there a current (2019) tutorial for configuring, in XML, spring integrations producers and consumers?
作为参考,这里是我 POM 的摘录,详细说明了我正在使用的版本:
For reference, here is an extract from my POM that details the versions I am using:
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-core</artifactId>
<version>5.1.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-kafka</artifactId>
<version>3.1.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-file</artifactId>
<version>5.1.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.batch</groupId>
<artifactId>spring-batch-core</artifactId>
<version>4.1.1.RELEASE</version>
</dependency>
给反对者的注意
github 上的链接已损坏,现在已修复,根据 Gary Russel 在他的回答中的评论
The link on github was broken and is now fixed, per comment by Gary Russel in his answer
推荐答案
参考手册 没有提供您需要的内容?
Does the reference manual not provide what you need?
例如:
<int-kafka:outbound-channel-adapter id="kafkaOutboundChannelAdapter"
kafka-template="template"
auto-startup="false"
channel="inputToKafka"
topic="foo"
sync="false"
message-key-expression="'bar'"
send-failure-channel="failures"
send-success-channel="successes"
error-message-strategy="ems"
partition-id-expression="2">
</int-kafka:outbound-channel-adapter>
<bean id="template" class="org.springframework.kafka.core.KafkaTemplate">
<constructor-arg>
<bean class="org.springframework.kafka.core.DefaultKafkaProducerFactory">
<constructor-arg>
<map>
<entry key="bootstrap.servers" value="localhost:9092" />
... <!-- more producer properties -->
</map>
</constructor-arg>
</bean>
</constructor-arg>
</bean>
和
<int-kafka:message-driven-channel-adapter
id="kafkaListener"
listener-container="container1"
auto-startup="false"
phase="100"
send-timeout="5000"
mode="record"
retry-template="template"
recovery-callback="callback"
error-message-strategy="ems"
channel="someChannel"
error-channel="errorChannel" />
<bean id="container1" class="org.springframework.kafka.listener.KafkaMessageListenerContainer">
<constructor-arg>
<bean class="org.springframework.kafka.core.DefaultKafkaConsumerFactory">
<constructor-arg>
<map>
<entry key="bootstrap.servers" value="localhost:9092" />
...
</map>
</constructor-arg>
</bean>
</constructor-arg>
<constructor-arg>
<bean class="org.springframework.kafka.listener.config.ContainerProperties">
<constructor-arg name="topics" value="foo" />
</bean>
</constructor-arg>
</bean>
等等...
这篇关于我需要当前易于遵循的说明来从 XML 配置 spring 集成 kafka的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!