首页 > 解决方案 > 我们可以在 Spring XML 配置文件中使用 Apache Camel 设置 Kafka 属性吗

问题描述

XML配置是否可以访问apache camel中的kafka属性

There is no kafka and spring XML configuration is available anywhere

<camelContext xmlns="http://camel.apache.org/schema/spring">
		<route>
			<from uri="direct:SpringXMLRouteStart" />
			<setHeader headerName="CamelHttpMethod">
			    <constant>GET</constant>
			</setHeader>
			<!-- To printout the routing message on the IDE console -->
			<to uri="http://localhost:8080/v1/get/WGS/inboundCMMessage1" />
		</route>
		<route>
			<from uri="http://localhost:8080/v1/get/WGS/inboundCMMessage1" />
			<to uri="kafka://localhost:9092?topic=customtopic&zookeeperHost=localhost:2181" />
		</route>
	</camelContext>

.....................我的错误......

org.xml.sax.SAXParseException: The reference to entity "zookeeperHost" must end with the ';' delimiter.

提前致谢

标签: xmlspring-bootapache-kafkaapache-camel

解决方案


由于您使用的是 XML,因此您不能像使用 Java DSL 那样在路由 URI 中使用 '&',所以这样做:

&amp;zookeeperHost=localhost:2181

推荐阅读