Sometimes you write something and then you nearly forget that you did it … although it is quite handy sometimes, here are a few lines of Apache Camel XML running in Eclipse Kura:
I just wanted to publish some random data from Kura to Kapua, without the need to code, deploy or build anything. Camel came to the rescue:
<routes xmlns="http://camel.apache.org/schema/spring">
<route id="route1">
<from uri="timer:1"/>
<setBody><simple>${bean:payloadFactory.create("value", ${random(100)})}</simple></setBody>
<to uri="kura-cloud:myapp/topic"/>
</route>
</routes>
Dropping this snippet into the default XML Camel router:
- Registers a Kura application named
myapp
- Creates a random number between 0 and 100 every second
- Converts this to the Kura Payload structure
- And publishes it on the topic
topic