open source iot gateway: tale of eclipse kura, apache camel and rhiot

36
Brought to you by Henryk Konsek Open source IoT gateway Tale of Eclipse Kura, Apache Camel and Rhiot

Upload: henryk-konsek

Post on 16-Apr-2017

1.103 views

Category:

Technology


3 download

TRANSCRIPT

Brought to you by Henryk Konsek

Open source IoT gatewayTale of Eclipse Kura, Apache Camel and Rhiot

Henryk Konsek

- engineer at Red Hat- open source contributor- Rhiot project founder

@hekonsek

Running Apache Camel in the Eclipse Kura server.

This talk@hekonsek

● Eclipse Kura● Apache Camel● Why Camel+Kura?● How Camel+Kura?

This talk@hekonsek

Eclipse Kura

@hekonsek

OSGi-based IoT gateway for field devices.

What is Eclipse Kura?@hekonsek

OSGi-based IoT gateway for the field devices.

OSGi● modularity system for Java● provides modules classpath separation● promotes hot runtime redeployments

What is Eclipse Kura?

OSGi Application Container (Eclipse Equinox, Concierge)

Java SE 7 / 8 (OpenJDK)

@hekonsek

What is Eclipse Kura?IoT gateway● collects messages from the edge devices (like sensors)● performs messages processing/aggregation/forwarding

OSGi-based IoT gateway for the field devices.

OSGi Application Container (Eclipse Equinox, Concierge)

Java SE 7 / 8 (OpenJDK)

Serial GPIO HID BLE I2C Field protocols

Networking Gateway Services Web UI Remote Management

Cloud Services Data Services EP

Connectivity and Delivery

@hekonsek

What is Eclipse Kura?

OSGi-based IoT gateway for the field devices.

@hekonsek

Gateway TL;DR;

A proxy between field devices and a data center

GATEWAY

@hekonsek

Eclipse. Donated by Eurotech (http://eurotech.com).

Who’s behind Kura?@hekonsek

Apache Camel

@hekonsek

A message routing framework.

What is Apache Camel?@hekonsek

How to orchestrate messages flow.

What is message routing?

● Apache Camel● Spring Integration● Mule

@hekonsek

- read message from JMS queue - transform to JSON- save to FTP and MongoDB

Crash course to the Apache Camel

from('jms:invoices'). transform { new Invoice(uuid(), it.in.body) }. marshal().json(Jackson). multicast().parallelProcessing(). to('ftp:myftp.com/invoices', 'mongodb:myDb?collection=invoices&operation=save')]

@hekonsek

Why Camel and Kura?

@hekonsek

Camel provides ~200 OSGi-ready connectors (JMS, REST, CoAP, AMQP, MQTT…)

How can Kura benefit from Camel?@hekonsek

Enterprise Integration Patterns (EIP)

How can Kura benefit from Camel?@hekonsek

Prevents messages overflow.

EIP - throttler@hekonsek

Provides SLA for the different channels.

EIP - throttler@hekonsek

Dynamically decide where to route the message.

EIP - content based router@hekonsek

Client side load balancing. Useful for field devices connectivity.

EIP - load balancer@hekonsek

How can I control which parts of a field device should be running at the given moment?

EIP - control bus@hekonsek

How Camel and Kura?

@hekonsek

Camel OSGi bundle is started from the Kura.

Kura + Camel: architecture@hekonsek

Invoke REST method every second.

Camel route module for Kura

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

@hekonsek

Just deploy the route as the OSGi bundle and enjoy Camel running the Kura.

Concerned about the lifecycle?@hekonsek

Display WiFi networks accessible near the field device using the web browser.

Fancy example #1

public class MyKuraRouter extends KuraRouter { @Override public void configure() throws Exception { from("netty4-http:http://0.0.0.0:18080"). to("bean:org.eclipse.kura.net.NetworkService?method=getAllWifiAccessPoints"); } }

@hekonsek

Start syncing cached data only when WiFi is accessible.

Fancy example #2

public class MyKuraRouter extends KuraRouter { @Override public void configure() throws Exception { from("kura-wifi:wlan0/mySSID"). to("controlbus:route?routeId=onlineSync&action=start");

from("file:///var/sensor/temperature"). routeId("onlineSync").autoStartup(false). to("netty4-http://api.mydatacenter.com"); } }

@hekonsek

Loading XML Camel routes at runtime using web UI.

Routes management@hekonsek

Camel will be soon a 1st class citizen in Kura.

Camel as a core part of the Kura@hekonsek

http://rhiot.io

Rhiot@hekonsek

Soon to be converted to Maven archetype :) .

Rhiot Kura quickstarts@hekonsek

git clone [email protected]:rhiot/quickstarts.git

cp -r quickstarts/kura-camel kura-camel

cd kura-camel

mvn install

CloudService user doesn’t know that payload is dispatched to Camel.

Rhiot CamelCloudService@hekonsek

CloudService cloudService = new DefaultCamelCloudService();CloudClient client = cloudService.newCloudClient("appId");

// Publish message to internal in-memory Camel queuecloudClient.publish("topic", "foo".getBytes(), 0, true, 0);

// Read message from Camel routefrom("kura-cloud:appId/topic"). to("netty4-http:http://example.com");

Use CloudService to publish message to any endpoint supported by Camel.

Rhiot CamelCloudService@hekonsek

CloudService cloudService = new DefaultCamelCloudService();CloudClient client = cloudService.newCloudClient("appId");

cloudClient.publish("amqp:topic", "foo".getBytes(), 0, true, 0);

Thank you!

Henryk [email protected]

@hekonsek