34
Brought to you by Henryk Konsek IoT gateway Dream Team Eclipse Kura and Apache Camel

IoT gateway dream team - Eclipse Kura and Apache Camel

Embed Size (px)

Citation preview

Brought to you by Henryk Konsek

IoT gateway Dream TeamEclipse Kura and Apache Camel

@hekonsek

Running Apache Camel in the Eclipse Kura OSGi container.

This talk

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

This talk

OSGi-based IoT gateway for the field devices.

What is Eclipse Kura?

OSGi-based IoT gateway for the field devices.

What is Eclipse Kura?

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

OSGi-based IoT gateway for the field devices.

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.

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.

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.

What is Eclipse Kura?

Gateway TL;DR;

Gateway

The proxy between field devices and the data center

Eurotech (http://eurotech.com)

Who’s behind Kura?

The message routing framework.

What is Apache Camel?

How to orchestrate messages flow.

What is message routing?

● Apache Camel● Spring Integration● Mule

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')]

I have my fancy Kura gateway already. Do I need Camel?

How can Kura benefit from Camel?

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

How can Kura benefit from Camel?

Enterprise Integration Patterns (EIP)

How can Kura benefit from Camel?

Prevents messages overflow.

EIP - throttler

Provides SLA for the different channels.

EIP - throttler

Dynamically decide where to route the message.

EIP - content based router

Client side load balancing. Useful for field devices connectivity.

EIP - load balancer

How can gateway provide transaction-like behavior when connecting to the non-transactional service?

EIP - idempotent consumer

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

EIP - control bus

Camel OSGi bundle is started from the Kura.

Kura + Camel: architecture

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("netty-http:http://app.mydatacenter.com/api"); } }

Don’t be!

Concerned about the deployment?

Don’t be!

Concerned about the lifecycle?

Don’t be!

Concerned about the OSGi services access?

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

Don’t be concerned!

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("netty-http:http://0.0.0.0:18080"). to("bean:org.eclipse.kura.net.NetworkService?method=getAllWifiAccessPoints"); } }

https://github.com/camel-labs/camel-labs

Camel Labs Kura components

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

Thank you!

● Eclipse Kura - https://eclipse.org/kura● Apache Camel - http://camel.apache.org● Enterprise Integaration Patterns - http://www.

enterpriseintegrationpatterns.com● Camel Kura - http://camel.apache.org/kura● Camel IoT Labs Kura extensions - https://github.

com/camel-labs/camel-labs/tree/master/iot#camel-kura-wifi-component

● demo code - https://github.com/hekonsek/camel-kura-wifi-demo