# Camel Kura router

**Avaliable since Rhiot 0.1.3**: Rhiot provides `io.rhiot.component.kura.router.RhiotKuraRouter` class, which extends `org.apache.camel.component.kura.KuraRouter` class from the Apache Camel [camel-kura](http://camel.apache.org/kura) module. While `KuraRouter` provides a generic base for Kura routes, it doesn't rely on the Kura-specific jars, because of limitations of the Apache Camel policy regarding adding 3rd parties repositories to the Camel (like Eclipse Kura repository). `RhiotKuraRouter` extends `KuraRouter` and enhances it with Kura-specific API.

This component can be used only in the Kura server - it doesn't work with a mini gateway.

## Maven dependency

In order to start using `RhiotKuraRouter`, Maven users should add the following dependency to their POM file:

io.rhiotcamel-kura${rhiot.version}

Adding Rhiot `camel-kura` module to your project, imports transitive Kura dependencies. This is big advantage over Apache Camel camel-kura module, which doesn't rely on Kura API and therefore doesn't import Kura jars.

## Usage

The principle of using `RhiotKuraRouter` is the same as using `KuraRouter` i.e. just extend `RhiotKuraRouter` class:

```
import io.rhiot.component.kura.router.RhiotKuraRouter;

class TestKuraRouter extends RhiotKuraRouter {

  @Override
  public void configure() throws Exception {
    from("direct:test")
     .to("mock:test");
  }

}
```

## Loading XML routes using SCR property

`RhiotKuraRouter` comes with a `RhiotKuraRouter#updated(Map<String, Object>)` 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](http://www.eurotech.com/en/products/software+services/everyware+cloud+m2m+platform/m2m+what+it+is), however you can use this callback outside the web UI and Everyware Cloud context.

Whenever `RhiotKuraRouter#updated(Map<String, Object>)` 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...

...new route will be automatically started (or updated if route with ID equal to `mqttLogger` already exists).

### 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.

We highly recommend to use our [Kura Camel quickstart](https://rhiot.gitbook.io/rhiotdocumentation/index-5/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.

&#x20;[![](https://3564220698-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-McjG74351JiHtmIEkgW%2Fsync%2F1b9703b756381f61ff5312e0c35865a1a003536d.png?generation=1624290696349496\&alt=media)](https://github.com/rhiot/rhiotdocumentation/tree/8c31a9d7d4bee1680d83639cefa800bec2a1f8df/gateway/kura_camel_routes_webui.png)

Our Kura Camel quickstart can be also used from the [EuroTech Everyware Cloud (EC)](http://www.eurotech.com/en/products/software+services/everyware+cloud+m2m+platform/m2m+what+it+is).

&#x20;[![](https://3564220698-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-McjG74351JiHtmIEkgW%2Fsync%2Fcee43bc85b7c1b2722d3893c73e81956edc4acbd.png?generation=1624290695948657\&alt=media)](https://github.com/rhiot/rhiotdocumentation/tree/8c31a9d7d4bee1680d83639cefa800bec2a1f8df/gateway/kura_camel_routes_webui.png)

## Camel Kura PojoSR test facility

This facility is intended to be used to test Camel routes to be deployed on a Kura server. Just instantiate a new `io.rhiot.component.kura.PojosrKuraServer` and call its `start` method passing your Camel route.

```
PojosrKuraServer pojosrKuraServer = new PojosrKuraServer();
MyKuraRouter startedKuraRouter = pojosrKuraServer.start(MyKuraRouter.class);
```

This will instantiate an OSGi registry, add your Camel route and its dependencies to the classpath and execute your route.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://rhiot.gitbook.io/rhiotdocumentation/index/camel_kura_router.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
