首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >最新(2019)首选的spring batch与kafka集成方式是什么?

最新(2019)首选的spring batch与kafka集成方式是什么?
EN

Stack Overflow用户
提问于 2019-03-21 06:18:47
回答 1查看 259关注 0票数 0

这是I need current easy to follow instructions for configuring spring integration kafka from XML的后续问题

Spring-integration-kafka在过去的几次迭代中发展了很多,许多旧的例子不再起作用。

特别是,这个从spring-batch世界到spring集成世界的bean将不会实例化,因为KafkaTemplate类没有实现MessagingTemplate。当前推荐的完成此集成的方式是什么?

代码语言:javascript
复制
<bean id="partitionHandler" class="org.springframework.batch.integration.partition.MessageChannelPartitionHandler">
    <property name="stepName" value="fm-step0002.messager"/>
    <property name="gridSize" value="3"/> 
    <property name="messagingOperations" ref="kafkaTemplate"/>
</bean>

下面是我的POM中的一个片段,其中显示了我正在使用的库的版本:

代码语言:javascript
复制
        <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>
        <dependency>
            <groupId>org.springframework.batch</groupId>
            <artifactId>spring-batch-infrastructure</artifactId>
            <version>4.1.1.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.batch</groupId>
            <artifactId>spring-batch-integration</artifactId>
            <version>4.1.1.RELEASE</version>
        </dependency>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-03-21 08:39:28

MessagingTemplate是Spring Integration的核心组件;它与您正在使用的代理(RabbitMQ、Kafka、JMS等)没有任何关系。

您使用默认通道配置模板(这是kafka出站端点的输入通道)。

请参见batch documentation (单击文档顶部的XML按钮,将示例从java更改为XML)。

这里的示例适用于JMS,但Kafka的配置与此类似。

代码语言:javascript
复制
<bean id="partitionHandler"
   class="org.springframework.batch.integration.partition.MessageChannelPartitionHandler">
  <property name="stepName" value="step1"/>
  <property name="gridSize" value="3"/>
  <property name="replyChannel" ref="outbound-replies"/>
  <property name="messagingOperations">
    <bean class="org.springframework.integration.core.MessagingTemplate">
      <property name="defaultChannel" ref="outbound-requests"/>
      <property name="receiveTimeout" value="100000"/>
    </bean>
  </property>
</bean>

<int:channel id="outbound-requests"/>
<int-jms:outbound-channel-adapter destination="requestsQueue"
    channel="outbound-requests"/>
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55270991

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档