简体   繁体   English

spring-integration-kafka xml多个主题不起作用

[英]spring-integration-kafka xml multiple topics not working

My project works just fine if there's just one topic defined in XML file. 如果XML文件中只定义了一个主题,那么我的项目就可以正常工作。 When I'm trying to add another topic, it just can't produce any message of either topic. 当我尝试添加另一个主题时,它只是无法生成任何一个主题的消息。 My XML file is like below: 我的XML文件如下所示:

<int-kafka:producer-configurations>
    <int-kafka:producer-configuration broker-list="127.0.0.1:9092"
                   topic="test"         
                   key-class-type="java.lang.String"
                   value-class-type="java.lang.String"
                   value-encoder="encoder"
                   key-encoder="encoder"
                   compression-type="none"
                />
    <int-kafka:producer-configuration broker-list="127.0.0.1:9092"
                   topic="test2"            
                   key-class-type="java.lang.String"
                   value-class-type="java.lang.String"
                   value-encoder="encoder"
                   key-encoder="encoder"
                   compression-type="none"
                />
</int-kafka:producer-configurations>

Anyone who knows about my problem would be great help, thanks 知道我的问题的人将对您有所帮助,谢谢

It looks like you are not providing any information as to which topic to route to. 您似乎没有提供有关路由到哪个主题的任何信息。

When there is only one topic, in that situation, it will be used. 如果只有一个主题,则在这种情况下将使用它。

If there are more than one, you will get an exception: 如果不止一个,您将得到一个例外:

throw new IllegalStateException("Could not send messages as there are multiple producer configurations " +
                "with no topic information found from the message header.");

By default, the adapter will look for the topic to route to in the kafka_topic message header. 默认情况下,适配器将在kafka_topic消息头中查找要路由到的主题。

You can also provide a topic-expression , eg topic-expression="headers['foo']" and the topic will be obtained from the foo header. 您还可以提供一个topic-expression ,例如topic-expression="headers['foo']" ,该主题将从foo标头中获取。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从spring-integration-kafka 1.0.0M(XML配置)转换为spring-integration-kafka 1.2.1(Java配置)? - How to convert from spring-integration-kafka 1.0.0M (XML config) to spring-integration-kafka 1.2.1 (Java config)? spring-integration-kafka 注释支持和示例 - spring-integration-kafka annotation support & example 在Spring-Integration-Kafka中使用@Gateway - Use @Gateway with Spring-Integration-Kafka Java 6中的Spring-Integration-Kafka示例 - Spring-Integration-Kafka examples in java 6 Kafka的Spring集成-配置多个主题 - Spring Integration for Kafka - Configuring Multiple Topics 如何使用xml配置升级到spring-integration-kafka 2.1.0.RELEASE? - How to upgrade to spring-integration-kafka 2.1.0.RELEASE with xml configuration? spring-integration-kafka 消息驱动通道适配器 XML 配置 - spring-integration-kafka message-driven-channel-adapter XML config spring-integration-kafka Maven构建错误:找不到spring-integration-kafka:jar:1.2.2.BUILD-SNAPSHOT - spring-integration-kafka Maven Build error: Can't find spring-integration-kafka:jar:1.2.2.BUILD-SNAPSHOT Spring-Integration-Kafka出站通道适配器发送消息 - Spring-Integration-Kafka outbound-channel-adapter Send message spring-integration-kafka:KafkaTemplate#setMessageConverter(RecordMessageConverter)无效 - spring-integration-kafka: KafkaTemplate#setMessageConverter(RecordMessageConverter) has no effect
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM