If you can't read please download the document
Upload
claus-ibsen
View
1.214
Download
1
Embed Size (px)
Citation preview
Microservices with Apache Camel
Claus Ibsen (@davsclaus)Principal Software Engineer, Red Hat
Your Speaker
Your Speaker
Principal Software Engineer at Red Hat
Apache Camel7 years working with Camel
Author of Camel in Action books
ContactE-mail: [email protected]
Twitter: @davsclaus
Blog: http://davsclaus.com
Shameful Advertisement
http://manning.com/ibsen2
Coupon Code
(39% discount)
camel39
Agenda
What is Apache Camel?
Camel Microservices
DemoStandalone
with Docker
with OpenShift 3 / Kubernetes
More Information
What is Apache Camel?
Quote from the website
What is Apache Camel?
Integration Framework
What is Apache Camel?
What is Enterprise Integration Patterns?
It's a book
What is Apache Camel?
Enterprise Integration Patterns
http://camel.apache.org/eip
What is Apache Camel?
EIP - Content Based Router
What is Apache Camel?
from newOrder
What is Apache Camel?
from newOrder choice
What is Apache Camel?
from newOrder choice when isWidget to widget
What is Apache Camel?
from newOrder choice when isWidget to widget otherwise to gadget
What is Apache Camel?
from(newOrder) choice when(isWidget) to(widget) otherwise to(gadget)
What is Apache Camel?
from(newOrder) .choice() .when(isWidget).to(widget) .otherwise().to(gadget);
What is Apache Camel?
Endpoint newOrder = endpoint("activemq:queue:newOrder");
from(newOrder) .choice() .when(isWidget).to(widget) .otherwise().to(gadget);
What is Apache Camel?
Endpoint newOrder = endpoint("activemq:queue:newOrder");Predicate isWidget = xpath("/order/product = 'widget'");
from(newOrder) .choice() .when(isWidget).to(widget) .otherwise().to(gadget);
What is Apache Camel?
Endpoint newOrder = endpoint("activemq:queue:newOrder");Predicate isWidget = xpath("/order/product = 'widget'");Endpoint widget = endpoint("activemq:queue:widget");Endpoint gadget = endpoint("activemq:queue:gadget");
from(newOrder) .choice() .when(isWidget).to(widget) .otherwise().to(gadget);
What is Apache Camel?
Java Code
public void configure() throws Exception { Endpoint newOrder = endpoint("activemq:queue:newOrder"); Predicate isWidget = xpath("/order/product = 'widget'"); Endpoint widget = endpoint("activemq:queue:widget"); Endpoint gadget = endpoint("activemq:queue:gadget");
from(newOrder) .choice() .when(isWidget).to(widget) .otherwise().to(gadget) .end(); }
What is Apache Camel?
Java Code
import org.apache.camel.Endpoint;import org.apache.camel.Predicate;import org.apache.camel.builder.RouteBuilder;
public class MyRoute extends RouteBuilder {
public void configure() throws Exception { Endpoint newOrder = endpoint("activemq:queue:newOrder"); Predicate isWidget = xpath("/order/product = 'widget'"); Endpoint widget = endpoint("activemq:queue:widget"); Endpoint gadget = endpoint("activemq:queue:gadget");
from(newOrder) .choice() .when(isWidget).to(widget) .otherwise().to(gadget) .end(); }}
What is Apache Camel?
Camel Java DSL
import org.apache.camel.builder.RouteBuilder;
public class MyRoute extends RouteBuilder {
public void configure() throws Exception { from("activemq:queue:newOrder") .choice() .when(xpath("/order/product = 'widget'")) .to("activemq:queue:widget") .otherwise() .to("activemq:queue:gadget") .end(); }}
What is Apache Camel?
Camel XML DSL
/order/product = 'widget'
What is Apache Camel?
Endpoint as URIs
/order/product = 'widget'
use file instead
What is Apache Camel?
Endpoint as URIs
/order/product = 'widget'
parameters
What is Apache Camel?
Java DSL is just Java
What is Apache Camel?
XML DSL is just XML
with XSD schema for validation/tooling
What is Apache Camel?
Camel's Architecture
What is Apache Camel?
150+ Components
What is Apache Camel?
150+ Components
+
+
+
+
+
+
=
+
+
+
Agenda
What is Apache Camel?
Camel Microservices
DemoStandalone
with Docker
with OpenShift 3 / Kubernetes
More Information
Running Camel as Microservices
StandaloneWeb Application
Camel Spring XMLApache Karaf
Camel Spring BootWildfly (wildfly-camel)
Camel CDIvert.x (vertx-camel)
Camel GuiceRest DSL
Camel Microservices
Apache Karaf
Camel Microservices
Apache Karaf
Apache Karaf
(boot)
Camel Microservices
Apache Karaf
Karaf FeaturesOSGi BundlesApache Karaf
(boot)
Camel Microservices
Apache Karaf
Karaf FeaturesOSGi BundlesApache Karaf
(boot)Karaf MavenPlugin
Camel Microservices
Apache Karaf
Karaf FeaturesOSGi BundlesApache Karaf
(boot)Karaf MavenPluginCustom Karaf
(with your app)
tar / zip file
Camel Microservices
Rest DSLUse Rest verbs
GET
POST
PUT
...
Swagger API
Pluggable Transport
Rest DSL example
Rest DSL example
Rest DSL example
Rest DSL example - add Swagger API
Agenda
What is Apache Camel?
Camel Microservices
DemoHello Service
Create the Camel projects
Docker
OpenShift v3
More Information
Demo - Hello Service
Hello Service
Demo - Hello Service
Hello Service
Hi I am New York. Hello Claus how are you today?
name=Claus
Demo - Hello Service
Java Standalone
Apache Tomcat
HTTP
Hello Service
Demo - Hello Service
Java Standalone
Apache Tomcat
HTTP
from timer to http to log
from servlet transform
Hello Service
Demo - Create the Camel Projects
Java Standalone
Apache Tomcat
HTTP
from timer to http to log
from servlet transform
Hello Service
camel-archetype-cdicamel-archetype-web
Demo - Create the Camel Projects
Using Command Shell
From Eclipse
Demo - Create the Camel Projects
camel-archetype-web
Ready to useout of the box
Demo - Create the Camel Projects
camel-archetype-cdi
Not readyWe need to change he code
Demo - Create the Camel Projects
add netty4-http endpoint
CMD + ALT4
Demo - Create the Camel Projects
configure netty4-http endpoint
Demo - Create the Camel Projects
change route to call netty
Demo - Create the Camel Projects
change bean to return a name
Demo - Overview
camel-archetype-cdicamel-archetype-web
Java Standalone
Apache Tomcat
HTTP 8080
from timer to http to log
from http transform
We are ready to run standalone
Demo - Running Standalone
mvn camel:run
Agenda
What is Apache Camel?
Camel Microservices
DemoHello Service
Create the Camel projects
Docker
OpenShift v3
More Information
Camel and Docker
Maven ProjectDocker MavenPluginDocker Image
build
Add Docker from Command Line
Add Docker from Eclipse / IDEA
CMD + ALT4
Docker Maven Plugin in pom.xml
Build Docker Containers
mvn clean install docker:build
Build Docker Containers
After build images in local Docker repository
camel-archetype-cdi
camel-archetype-web
Agenda
What is Apache Camel?
Camel Microservices
DemoHello Service
Create the Camel projects
Docker
OpenShift v3
More Information
Static
camel-archetype-cdicamel-archetype-web
Java Standalone
Apache Tomcat
from timer to http to log
from servlet transform
HTTP 8080
hostname:portis static / hardcoded
Dynamic
camel-archetype-cdicamel-archetype-web
Java Standalone
Apache Tomcat
from timer to http to log
from servlet transform
Service
KubernetesService
What is a Kubernetes Service
Network Connection to one or more Pods
Own fixed IP address and port
http://fabric8.io/guide/services.htmlhttp://kubernetes.io/v1.1/docs/user-guide/services.html
What is a Kubernetes Service
kube-proxy on client
http://fabric8.io/guide/services.htmlhttp://kubernetes.io/v1.1/docs/user-guide/services.html
Java Standalone
Apache Tomcat
from timer to http to log
from servlet transform
kube-proxyKubernetesMaster
servicechanges
Service
enlist
Define Kubernetes Service
Use fabric8
command
Apache Tomcat
from servlet transform
Service
Define Kubernetes Service
Defined in pom.xml in
Apache Tomcat
from servlet transform
Service
Container Port = Inside Docker Container(e.g. the port of Apache Tomcat)Service Port = OutsideConsumers of Service to useName of service
Generated kubernetes.json
Apache Tomcat
from http choice setBody
Service
Use Kubernetes Services
Java Standalone
from timer to http to log
Environment VariablesHostname
Port
Injected by Kuberneteswhen starting a pod
Camel - Use Kubernetes Service
Use {{service:name}} in Camel
Java Standalone
from timer to http to log
Microservice Demo - Ready for launch!
camel-archetype-cdicamel-archetype-web
Java Standalone
Apache Tomcat
from timer to http to log
from http transform
Service
Service definedReady to deploy to Kubernetes
Deploy - myweb
mvn -Pf8-local-deploy
Apache Tomcat
from http transform
Service
Deploy - camel-archetype-cdi
mvn -Pf8-local-deploy
Java Standalone
from timer to http to log
fabric8 web console
http://fabric8.vagrant.f8
OpenShift 3 CLI
oc get pods
docker CLI is also possibledocker imagesdocker ps
OpenShift 3 CLI
oc get services
OpenShift 3 CLI
oc logs -f
OpenShift 3 CLI
oc get routes
Scaling up / down
change controller replicas
Scaling up / down
Service Load Balancing
Agenda
What is Apache Camel?
Camel Microservices
DemoHello Service
Create the Camel projects
Docker
OpenShift v3
More Information
More information
Apache Camel Microserviceshttp://camel.apache.org/camel-boot
Fabric8http://fabric8.io
chat room #fabric8 on freenode
Medium Fabric8 (blogs and videos)https://medium.com/fabric8-io
Click to edit the title text format
Click to edit the outline text format
Click to edit the outline text formatSecond Outline LevelThird Outline LevelFourth Outline LevelFifth Outline LevelSixth Outline LevelSeventh Outline LevelEighth Outline LevelNinth Outline Level