Presentation is loading. Please wait.

Presentation is loading. Please wait.

Communication Between Camel Routes

Similar presentations


Presentation on theme: "Communication Between Camel Routes"— Presentation transcript:

1 Communication Between Camel Routes
JB Onofré

2 Agenda Background Why multiple routes ? Local communication
Remote communication Q&A

3 Who I am Jean-Baptiste (JB) Onofré <jbonofre@apache.org>
ASF Member PMC for Karaf, ServiceMix, ACE, Syncope, ... Committer for Camel, Archiva Software architect at Talend (

4 Divide to reign (Game Of Code, CamelOne 2013)
Why multiple routes ? A route is a … So it can be ... Divide to reign (Game Of Code, CamelOne 2013)

5 Benefits of multiple routes
Reuse of existing routes Maintain “atomic” routes by different teams Each route has its own life cycle (provisioning, upgrade of a route without impacting another one, …) Easier to test (utests and itests) Scalable on multiple machines (remote)

6 Communication between local routes – Direct
Direct component (camel-core) Synchronous Local to the same Camel context Machine CamelContext Route1 Route2

7 Communication between local routes – Direct
<?xml version=”1.0” encoding=”UTF-8”?> <blueprint> <camelContext> <route id=”route1”> <from uri=”timer:simple?period=5000”/> <setBody> <simple>Hello CamelOne</simple> </setBody> <to uri=”direct:route2”/> </route> <route id=”route2”> <from uri=”direct:route2”/> <to uri=”stream:out”/> </camelContext> </blueprint>

8 Communication between local routes – Direct-VM
Direct-VM component (camel-core) Extension of the Direct component (Synchronous) Communication between routes from different CamelContexts Machine CamelContext1 CamelContext2 Route1 Route2

9 Communication between local routes – Direct-VM
<?xml version=”1.0” encoding=”UTF-8”?> <blueprint> <camelContext> <route id=”route1”> <from uri=”timer:simple?period=5000”/> <setBody> <simple>Hello CamelOne</simple> </setBody> <to uri=”direct-vm:route2”/> </route> </camelContext> </blueprint> <?xml version=”1.0” encoding=”UTF-8”?> <blueprint> <camelContext> <route id=”route2”> <from uri=”direct-vm:route2”/> <to uri=”stream:out”/> </route> </camelContext> </blueprint>

10 Communication between local routes – SEDA
SEDA (Staged Event-Driven Architecture) (camel-core) Asynchronous Use JVM BlockingQueue on the Producer Different thread on the consumers (possible to have multiple consumers) Machine CamelContext Route1 Route2 BlockingQueue

11 Communication between local routes – SEDA
<?xml version=”1.0” encoding=”UTF-8”?> <blueprint> <camelContext> <route id=”route1”> <from uri=”timer:simple?period=5000”/> <setBody> <simple>Hello CamelOne</simple> </setBody> <to uri=”seda:route2”/> </route> <route id=”route2”> <from uri=”seda:route2”/> <to uri=”stream:out”/> </camelContext> </blueprint>

12 Communication between local routes – VM
VM component (camel-core) Extension of the SEDA component (Asynchronous) Communication between routes from different CamelContexts Machine CamelContext1 CamelContext2 Route1 Route2 BlockingQueue

13 Communication between local routes – VM
<?xml version=”1.0” encoding=”UTF-8”?> <blueprint> <camelContext> <route id=”route1”> <from uri=”timer:simple?period=5000”/> <setBody> <simple>Hello CamelOne</simple> </setBody> <to uri=”vm:route2”/> </route> </camelContext> </blueprint> <?xml version=”1.0” encoding=”UTF-8”?> <blueprint> <camelContext> <route id=”route2”> <from uri=”vm:route2”/> <to uri=”stream:out”/> </route> </camelContext> </blueprint>

14 Communication between routes
Camel provides components for local routes communication Direct/direct-vm: synchronous SEDA/VM: asynchronous Different ways for remote routes communication. For this presentation: REST (CXF RS): synchronous JMS (ActiveMQ): asynchronous Hazelcast (Cellar): asynchronous

15 Remote communication between routes – REST
RESTLET component (camel-restlet, but can use CXF) Synchronous Similar to direct but in remote Machine Machine CamelContext CamelContext Route1 Route2

16 REST <?xml version=”1.0” encoding=”UTF-8”?> <blueprint>
<camelContext> <route id=”route1”> <from uri=”timer:fire?period=5000”/> <setBody> <simple>Hello CamelOne</simple> </setBody> <to uri=”restlet: </route> </camelContext> </blueprint> <?xml version=”1.0” encoding=”UTF-8”?> <blueprint> <camelContext> <route id=”route2”> <from uri=”restlet: <to uri=”stream:out”/> </route> </camelContext> </blueprint>

17 REST – Pros/Cons Pros: Cons:
Directly supported in Camel thanks to the camel-restlet or camel-cxf components Very easy to use (especially with RESTLET) Support load balancing (for instance mod_proxy_balancer) Similar to direct but in remote Cons: Overhead depending of the data format Order of startup (error handling)

18 Remote communication between routes – JMS
JMS component (camel-jms) Async Machine ActiveMQ Machine CamelContext CamelContext Route1 Route2 Queue

19 ActiveMQ JMS <?xml version=”1.0” encoding=”UTF-8”?>
<blueprint> <camelContext> <route id=”route1”> <from uri=”timer:simple?period=5000”/> <setBody> <simple>Hello CamelOne</simple> </setBody> <to uri=”jms:queue:route”/> </route> </camelContext> </blueprint> <?xml version=”1.0” encoding=”UTF-8”?> <blueprint> <camelContext> <route id=”route2”> <from uri=”jms:queue:route”/> <to uri=”stream:out”/> </route> </camelContext> </blueprint>

20 JMS – Pros/Cons Pros: Cons: Support important load
Support advanced features: messages persistence, network of brokers, master/slave Cons: Require an additional middleware (ActiveMQ)

21 Remote communication between routes – Karaf Cellar/Hazelcast
Hazelcast component (camel-hazelcast) Async (SEDA) Leverage Karaf Cellar (powered by Hazelcast) Machine Cellar/Hazelcast Machine Cellar/Hazelcast CamelContext CamelContext Route1 Route2 DataGrid

22 Karaf Cellar ? Apache Karaf subproject
Each node embeds Hazelcast instance (no point of failure) Provides data grid and cluster events Used for “clustered provisioning”

23 Karaf Cellar Architecture
Hazelcast Hazelcast Cellar Cellar Cluster Event Consumer DataGrid Cluster Event Consumer Cluster Event Handler Cluster Event Handler Cluster Event Producer Cluster Event Producer Synchronizer Local listeners Synchronizer Local listeners Shell commands MBeans Shell commands MBeans Local resources (bundles, features, config) Local resources (bundles, features, config)

24 Karaf Cellar Components
Cluster event producer: creates a cluster event and broadcast it to the other cluster nodes Cluster event consumer: receives a cluster event and delegates the handling Cluster event handler: handles a specific cluster event (bundles, features, config, …) Synchronizers: call at the Cellar bootstrap to synchronize the local node state with the cluster state Local listeners: listens for local resource events (bundles, features, config, …), and creates a cluster event sent to the other nodes Shell commands (cluster:*)/MBeans: manipulate resources on the cluster

25 Karaf Cellar and Camel Cellar provides Hazelcast support in Karaf, including classloader handling, configuration support (installing etc/hazelcast.xml), … Camel-hazelcast component uses the Hazelcast instance provided by Cellar

26 Hazelcast <?xml version=”1.0” encoding=”UTF-8”?>
<blueprint> <camelContext> <route id=”route1”> <from uri=”timer:simple?period=5000”/> <setBody> <simple>Hello CamelOne</simple> </setBody> <to uri=”hazelcast:seda:route”/> </route> </camelContext> </blueprint> <?xml version=”1.0” encoding=”UTF-8”?> <blueprint> <camelContext> <route id=”route2”> <from uri=”hazelcast:seda:route”/> <to uri=”stream:out”/> </route> </camelContext> </blueprint>

27 Hazelcast – Pros/Cons Pros: Cons:
Similar to SEDA but for remote communication No equirement to use an external middleware (Cellar) Support Hazelcast advanced features: discovery/multicast, cache persistence, near cache, enviction, ... Cons: Not really used :(

28 So ... It's good to split a big route into sub-routes
Camel directly supports local route communication But Camel provides a set of components that allows you to communicate with remote routes Thanks to remote routes communication, you can implement a distributed architecture

29 Thank you ! Questions ? Keep in touch: twitter: @jbonofre e-mail: jbonofre@apache.org


Download ppt "Communication Between Camel Routes"

Similar presentations


Ads by Google