In my previous post about Camel and Kura integration I demonstrated how to easily deploy Camel routes into Kura using Rhiot. In this article I would like to elaborate a little bit on how to manage Camel routes from the level of the Kura web UI.
Loading XML Routes Using SCR Property
RhiotKuraRouter comes with a RhiotKuraRouter#updated(Map) method. The primary purpose of this callback is to allow a router to be a SCR component configured using the Kura Web UI and EuroTech Everyware Cloud, however you can use this callback outside the web UI and Everyware Cloud context.
Whenever RhiotKuraRouter#updated(Map) callback is executed, RhiotKuraRouter tries to read camel.route.xml property value (RhiotKuraConstants.XML_ROUTE_PROPERTY key constant), to parse its value and load it as an XML Camel routes. For example if the camel.route.xml property will be set to the following value...
<routes xmlns="http://camel.apache.org/schema/spring"> <route id="mqttLogger"> <from uri="paho:topic?brokerUrl=tcp:brokerhost:1883"/> <to uri="log:messages"/> </route> </routes>
...new route will be automatically started (or updated if route with ID equal to mqttLogger already exists).
All the above basically mean that if you register your Kura router as OSGi declarative service, you will be able to dynamically load and update XML routes using OSGi configuration admin service.
Managing XML Camel Routes Using Web UI
All RhiotKuraRouter instances implements Kura's ConfigurableComponent interface. It means that those can be configured using Kura web UI.
I highly recommend to use Rhiot Kura Camel quickstart as a template for creating Kura Camel routers. Our quickstart is configured as SCR component, so you can just deploy it to the Kura server and see your gateway route module deployed as a configurable service. To specify the route XML that should be loaded by a Camel context running in a deployed module, edit the camel.route.xml service property and click Apply button. As soon as Apply button is clicked, the route will be parsed and loaded.
Our Kura Camel quickstart can be also used from the EuroTech Everyware Cloud (EC).
Maintenance of the Kura Routes at Runtime
The ability to maintain Camel routes from web UI without restarting a Kura server is extremely important when it comes to the long term maintenance of your IoT gateway solution. It allows to modify a flow of the existing message routes or create new rules without affecting an uptime of your production environment.
Production-level grade IoT gateway (Kura) and powerful messaging framework (Camel) are an example of a perfect combination of two mature technologies which used together result in a solid, but flexible Internet Of Things solution.