[英]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.