You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

Eclipse Kura component

This documentation page covers the integration options of Camel with the Eclipse Kura M2M gateway.

KuraRouter activator

The easiest way to deploy Apache Camel routes into the Kura is to create an OSGi bundle containing the class extending org.apache.camel.kura.KuraRouter class:

public class MyKuraRouter extends KuraRouter {

    @Override
    public void configure() throws Exception {
        from("timer:trigger").
          to("netty-http:http://app.mydatacenter.com/api");
    }

}

Kura router starts its own OSGi-aware CamelContext. It means that for every class extending KuraRouter, there will be a dedicated CamelContext instance. Ideally we recommend to deploy one KuraRouter per OSGi bundle.

Deploying KuraRouter

Bundle containing your Kura router class should import the following bundles in the OSGi manifest:

Import-Package: org.osgi.framework;version="1.3.0",
org.slf4j;version="1.6.4",
org.apache.camel,org.apache.camel.impl,org.apache.camel.core.osgi,org.apache.camel.builder,org.apache.camel.model,
org.apache.camel.kura

Keep in mind that you don't have to import every Camel component bundle you plan to use in your routes, as Camel components are resolved as the services on the runtime level.

Before you deploy your router bundle, be sure that you have deployed (and started) the following Camel core bundles (using Kura GoGo shell)...

install file:///home/user/.m2/repository/org/apache/camel/camel-core/2.15.0/camel-core-2.15.0.jar
start <camel-core-bundle-id>
install file:///home/user/.m2/repository/org/apache/camel/camel-core-osgi/2.15.0/camel-core-osgi-2.15.0.jar
start <camel-core-osgi-bundle-id>
install file:///home/user/.m2/repository/org/apache/camel/camel-kura/2.15.0/camel-kura-2.15.0.jar 
start <camel-kura-bundle-id>

...and all the components you plan to use in your routes:

install file:///home/user/.m2/repository/org/apache/camel/camel-stream/2.15/camel-stream-2.15.jar
start <camel-kura-bundle-id>

Then finally deploy your router bundle:

install file:///home/user/.m2/repository/com/example/myrouter/1.0/myrouter-1.0.jar
start <your-bundle-id>

KuraRouter utilities 

 Kura router base class provides many useful utilities. This section explores each of those.

SLF4J logger

public class MyKuraRouter extends KuraRouter {

    @Override
    public void configure() throws Exception {
		log.info("Configuring Camel routes!");
        ...
    }

}

BundleContext

public class MyKuraRouter extends KuraRouter {

    @Override
    public void configure() throws Exception {
		ServiceReference<MyService> serviceRef = bundleContext.getServiceReference(LogService.class.getName());
		MyService myService = content.getService(serviceRef);
        ...
    }

}

 

  • No labels