Read MQTT topic of received message in Camel Route -
i trying configure apache camel spring route. consume messages mqtt , print them topic. how topic message published to?
i'm using apache camel 2.16.1
camel-context.xml
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd"> <camelcontext xmlns="http://camel.apache.org/schema/spring" id="mqttcamel"> <route> <from uri="mqtt:iot?host=tcp://iot.eclipse.org:1883&subscribetopicnames=#" /> <convertbodyto type="java.lang.string" /> <to uri="stream:out" /> </route> </camelcontext> </beans>
with mqtt component, topic stored in header called "camelmqttsubscribetopic":
from("mqtt:foo?subscribetopicname=#&host=tcp://127.0.0.1:1883") .log("message read topic ${in.header.camelmqttsubscribetopic}.");
Comments
Post a Comment