open source iot gateway - eclipsecon europe 2019...open source iot gateway tale of eclipse kura,...

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

Upload: others

Post on 22-May-2020

16 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Open source IoT gateway - EclipseCon Europe 2019...Open source IoT gateway Tale of Eclipse Kura, Apache Camel and Rhiot Henryk Konsek-engineer at Red Hat-open source contributor-Rhiot

Brought to you by Henryk Konsek

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

Page 2: Open source IoT gateway - EclipseCon Europe 2019...Open source IoT gateway Tale of Eclipse Kura, Apache Camel and Rhiot Henryk Konsek-engineer at Red Hat-open source contributor-Rhiot

Henryk Konsek

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

@hekonsek

Page 3: Open source IoT gateway - EclipseCon Europe 2019...Open source IoT gateway Tale of Eclipse Kura, Apache Camel and Rhiot Henryk Konsek-engineer at Red Hat-open source contributor-Rhiot

Running Apache Camel in the Eclipse Kura server.

This talk@hekonsek

Page 4: Open source IoT gateway - EclipseCon Europe 2019...Open source IoT gateway Tale of Eclipse Kura, Apache Camel and Rhiot Henryk Konsek-engineer at Red Hat-open source contributor-Rhiot

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

This talk@hekonsek

Page 5: Open source IoT gateway - EclipseCon Europe 2019...Open source IoT gateway Tale of Eclipse Kura, Apache Camel and Rhiot Henryk Konsek-engineer at Red Hat-open source contributor-Rhiot

Eclipse Kura

@hekonsek

Page 6: Open source IoT gateway - EclipseCon Europe 2019...Open source IoT gateway Tale of Eclipse Kura, Apache Camel and Rhiot Henryk Konsek-engineer at Red Hat-open source contributor-Rhiot

OSGi-based IoT gateway for field devices.

What is Eclipse Kura?@hekonsek

Page 7: Open source IoT gateway - EclipseCon Europe 2019...Open source IoT gateway Tale of Eclipse Kura, Apache Camel and Rhiot Henryk Konsek-engineer at Red Hat-open source contributor-Rhiot

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

Page 8: Open source IoT gateway - EclipseCon Europe 2019...Open source IoT gateway Tale of Eclipse Kura, Apache Camel and Rhiot Henryk Konsek-engineer at Red Hat-open source contributor-Rhiot

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

Page 9: Open source IoT gateway - EclipseCon Europe 2019...Open source IoT gateway Tale of Eclipse Kura, Apache Camel and Rhiot Henryk Konsek-engineer at Red Hat-open source contributor-Rhiot

What is Eclipse Kura?

OSGi-based IoT gateway for the field devices.

@hekonsek

Page 10: Open source IoT gateway - EclipseCon Europe 2019...Open source IoT gateway Tale of Eclipse Kura, Apache Camel and Rhiot Henryk Konsek-engineer at Red Hat-open source contributor-Rhiot

Gateway TL;DR;

A proxy between field devices and a data center

GATEWAY

@hekonsek

Page 11: Open source IoT gateway - EclipseCon Europe 2019...Open source IoT gateway Tale of Eclipse Kura, Apache Camel and Rhiot Henryk Konsek-engineer at Red Hat-open source contributor-Rhiot

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

Who’s behind Kura?@hekonsek

Page 12: Open source IoT gateway - EclipseCon Europe 2019...Open source IoT gateway Tale of Eclipse Kura, Apache Camel and Rhiot Henryk Konsek-engineer at Red Hat-open source contributor-Rhiot

Apache Camel

@hekonsek

Page 13: Open source IoT gateway - EclipseCon Europe 2019...Open source IoT gateway Tale of Eclipse Kura, Apache Camel and Rhiot Henryk Konsek-engineer at Red Hat-open source contributor-Rhiot

A message routing framework.

What is Apache Camel?@hekonsek

Page 14: Open source IoT gateway - EclipseCon Europe 2019...Open source IoT gateway Tale of Eclipse Kura, Apache Camel and Rhiot Henryk Konsek-engineer at Red Hat-open source contributor-Rhiot

How to orchestrate messages flow.

What is message routing?

● Apache Camel● Spring Integration● Mule

@hekonsek

Page 15: Open source IoT gateway - EclipseCon Europe 2019...Open source IoT gateway Tale of Eclipse Kura, Apache Camel and Rhiot Henryk Konsek-engineer at Red Hat-open source contributor-Rhiot

- 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

Page 16: Open source IoT gateway - EclipseCon Europe 2019...Open source IoT gateway Tale of Eclipse Kura, Apache Camel and Rhiot Henryk Konsek-engineer at Red Hat-open source contributor-Rhiot

Why Camel and Kura?

@hekonsek

Page 17: Open source IoT gateway - EclipseCon Europe 2019...Open source IoT gateway Tale of Eclipse Kura, Apache Camel and Rhiot Henryk Konsek-engineer at Red Hat-open source contributor-Rhiot

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

How can Kura benefit from Camel?@hekonsek

Page 18: Open source IoT gateway - EclipseCon Europe 2019...Open source IoT gateway Tale of Eclipse Kura, Apache Camel and Rhiot Henryk Konsek-engineer at Red Hat-open source contributor-Rhiot

Enterprise Integration Patterns (EIP)

How can Kura benefit from Camel?@hekonsek

Page 19: Open source IoT gateway - EclipseCon Europe 2019...Open source IoT gateway Tale of Eclipse Kura, Apache Camel and Rhiot Henryk Konsek-engineer at Red Hat-open source contributor-Rhiot

Prevents messages overflow.

EIP - throttler@hekonsek

Page 20: Open source IoT gateway - EclipseCon Europe 2019...Open source IoT gateway Tale of Eclipse Kura, Apache Camel and Rhiot Henryk Konsek-engineer at Red Hat-open source contributor-Rhiot

Provides SLA for the different channels.

EIP - throttler@hekonsek

Page 21: Open source IoT gateway - EclipseCon Europe 2019...Open source IoT gateway Tale of Eclipse Kura, Apache Camel and Rhiot Henryk Konsek-engineer at Red Hat-open source contributor-Rhiot

Dynamically decide where to route the message.

EIP - content based router@hekonsek

Page 22: Open source IoT gateway - EclipseCon Europe 2019...Open source IoT gateway Tale of Eclipse Kura, Apache Camel and Rhiot Henryk Konsek-engineer at Red Hat-open source contributor-Rhiot

Client side load balancing. Useful for field devices connectivity.

EIP - load balancer@hekonsek

Page 23: Open source IoT gateway - EclipseCon Europe 2019...Open source IoT gateway Tale of Eclipse Kura, Apache Camel and Rhiot Henryk Konsek-engineer at Red Hat-open source contributor-Rhiot

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

EIP - control bus@hekonsek

Page 24: Open source IoT gateway - EclipseCon Europe 2019...Open source IoT gateway Tale of Eclipse Kura, Apache Camel and Rhiot Henryk Konsek-engineer at Red Hat-open source contributor-Rhiot

How Camel and Kura?

@hekonsek

Page 25: Open source IoT gateway - EclipseCon Europe 2019...Open source IoT gateway Tale of Eclipse Kura, Apache Camel and Rhiot Henryk Konsek-engineer at Red Hat-open source contributor-Rhiot

Camel OSGi bundle is started from the Kura.

Kura + Camel: architecture@hekonsek

Page 26: Open source IoT gateway - EclipseCon Europe 2019...Open source IoT gateway Tale of Eclipse Kura, Apache Camel and Rhiot Henryk Konsek-engineer at Red Hat-open source contributor-Rhiot

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

Page 27: Open source IoT gateway - EclipseCon Europe 2019...Open source IoT gateway Tale of Eclipse Kura, Apache Camel and Rhiot Henryk Konsek-engineer at Red Hat-open source contributor-Rhiot

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

Concerned about the lifecycle?@hekonsek

Page 28: Open source IoT gateway - EclipseCon Europe 2019...Open source IoT gateway Tale of Eclipse Kura, Apache Camel and Rhiot Henryk Konsek-engineer at Red Hat-open source contributor-Rhiot

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

Page 29: Open source IoT gateway - EclipseCon Europe 2019...Open source IoT gateway Tale of Eclipse Kura, Apache Camel and Rhiot Henryk Konsek-engineer at Red Hat-open source contributor-Rhiot

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

Page 30: Open source IoT gateway - EclipseCon Europe 2019...Open source IoT gateway Tale of Eclipse Kura, Apache Camel and Rhiot Henryk Konsek-engineer at Red Hat-open source contributor-Rhiot

Loading XML Camel routes at runtime using web UI.

Routes management@hekonsek

Page 31: Open source IoT gateway - EclipseCon Europe 2019...Open source IoT gateway Tale of Eclipse Kura, Apache Camel and Rhiot Henryk Konsek-engineer at Red Hat-open source contributor-Rhiot

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

Camel as a core part of the Kura@hekonsek

Page 32: Open source IoT gateway - EclipseCon Europe 2019...Open source IoT gateway Tale of Eclipse Kura, Apache Camel and Rhiot Henryk Konsek-engineer at Red Hat-open source contributor-Rhiot

http://rhiot.io

Rhiot@hekonsek

Page 33: Open source IoT gateway - EclipseCon Europe 2019...Open source IoT gateway Tale of Eclipse Kura, Apache Camel and Rhiot Henryk Konsek-engineer at Red Hat-open source contributor-Rhiot

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

Page 34: Open source IoT gateway - EclipseCon Europe 2019...Open source IoT gateway Tale of Eclipse Kura, Apache Camel and Rhiot Henryk Konsek-engineer at Red Hat-open source contributor-Rhiot

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");

Page 35: Open source IoT gateway - EclipseCon Europe 2019...Open source IoT gateway Tale of Eclipse Kura, Apache Camel and Rhiot Henryk Konsek-engineer at Red Hat-open source contributor-Rhiot

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);

Page 36: Open source IoT gateway - EclipseCon Europe 2019...Open source IoT gateway Tale of Eclipse Kura, Apache Camel and Rhiot Henryk Konsek-engineer at Red Hat-open source contributor-Rhiot

Thank you!

Henryk [email protected]

@hekonsek