Red Hat Microservices Architecture Day - New York, November 2015. Presented by Claus Ibsen.
Apache Camel is a very popular integration library that works very well with microservice architecture. This talk introduces you to Apache Camel and how you can easily get started with Camel on your computer...
Red Hat Microservices Architecture Day - New York, November 2015. Presented by Claus Ibsen.
Apache Camel is a very popular integration library that works very well with microservice architecture. This talk introduces you to Apache Camel and how you can easily get started with Camel on your computer. Then we cover how to create new Camel projects from scratch as microservices, which you can boot using Camel or Spring Boot, or other micro containers such as Jetty or fat JARs. We then take a look at what options you have for monitoring and managing your Camel microservices using tooling such as Jolokia, and hawtio web console.
Size: 2.14 MB
Language: en
Added: Apr 20, 2016
Slides: 101 pages
Slide Content
Microservices with Apache Camel
Claus Ibsen (@davsclaus)
Principal Software Engineer, Red Hat
Your Speaker
Your Speaker
●Principal Software Engineer at Red Hat
●Apache Camel
●7 years working with Camel
●Author of Camel in Action books
●Contact
●E-mail: [email protected]
●Twitter: @davsclaus
●Blog: http://davsclaus.com
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
<route>
<from uri="activemq:queue:newOrder"/>
<choice>
<when>
<xpath>/order/product = 'widget'</xpath>
<to uri="activemq:queue:widget"/>
</when>
<otherwise>
<to uri="activemq:queue:gadget"/>
</otherwise>
</choice>
</route>
What is Apache Camel?
●Endpoint as URIs
<route>
<from uri="file:inbox/orders"/>
<choice>
<when>
<xpath>/order/product = 'widget'</xpath>
<to uri="activemq:queue:widget"/>
</when>
<otherwise>
<to uri="activemq:queue:gadget"/>
</otherwise>
</choice>
</route>
use file instead
What is Apache Camel?
●Endpoint as URIs
<route>
<from uri="file:inbox/orders?delete=true"/>
<choice>
<when>
<xpath>/order/product = 'widget'</xpath>
<to uri="activemq:queue:widget"/>
</when>
<otherwise>
<to uri="activemq:queue:gadget"/>
</otherwise>
</choice>
</route>
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
●Demo
●Standalone
●with Docker
●with OpenShift 3 / Kubernetes
●More Information
Running Camel as Microservices
Standalone Web Application
Camel Spring XML Apache Karaf
Camel Spring Boot Wildfly (wildfly-camel)
Camel CDI vert.x (vertx-camel)
Camel Guice Rest DSL
Camel Microservices
●Apache Karaf
Karaf Features
OSGi Bundles
Apache Karaf
(boot)
Karaf Maven
Plugin
Custom Karaf
(with your app)
tar / zip file
Camel Microservices
●Rest DSL
●Use 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
●Demo
●Hello 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-cdi camel-archetype-web
Demo - Create the Camel Projects
●camel-archetype-web
Ready to use
out of the box
Demo - Create the Camel Projects
●camel-archetype-cdi
Not ready
We need to change
he code
Demo - Create the Camel Projects
●add netty4-http endpoint
CMD + ALT
4
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-cdi camel-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
●Demo
●Hello Service
●Create the Camel projects
●Docker
●OpenShift v3
●More Information
Build Docker Containers
●After build images in local Docker repository
camel-archetype-cdi
camel-archetype-web
Agenda
●What is Apache Camel?
●Camel Microservices
●Demo
●Hello Service
●Create the Camel projects
●Docker
●OpenShift v3
●More Information
Static
●camel-archetype-cdi camel-archetype-web
Java Standalone Apache Tomcat
from timer
to http
to log
from servlet
transform
HTTP 8080
hostname:port
is static / hardcoded
Dynamic
●camel-archetype-cdi camel-archetype-web
Java Standalone Apache Tomcat
from timer
to http
to log
from servlet
transform
S
e
r
v
i
c
e
Kubernetes
Service
What is a Kubernetes Service
●Network Connection to one or more Pods
●Own fixed IP address and port
http://fabric8.io/guide/services.html
http://kubernetes.io/v1.1/docs/user-guide/services.html
What is a Kubernetes Service
●kube-proxy on client
http://fabric8.io/guide/services.html
http://kubernetes.io/v1.1/docs/user-guide/services.html
Java Standalone Apache Tomcat
from timer
to http
to log
from servlet
transform
k
u
b
e
-
p
r
o
x
y
Kubernetes
Master
service
changes
S
e
r
v
i
c
e
enlist
Define Kubernetes Service
●Use fabric8
command
Apache Tomcat
from servlet
transform
S
e
r
v
i
c
e
Define Kubernetes Service
●Defined in pom.xml in <properties>
Apache Tomcat
from servlet
transform
S
e
r
v
i
c
e
Container Port = Inside Docker Container
(e.g. the port of Apache Tomcat)
Service Port = Outside
Consumers of Service to use
Name of service
Generated kubernetes.json
Apache Tomcat
from http
choice
setBody
S
e
r
v
i
c
e
Use Kubernetes Services
Java Standalone
from timer
to http
to log
●Environment Variables
●Hostname
●Port
Injected by Kubernetes
when 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-cdi camel-archetype-web
Java Standalone Apache Tomcat
from timer
to http
to log
from http
transform
S
e
r
v
i
c
e
Service defined
Ready to deploy to Kubernetes
Deploy - myweb
●mvn -Pf8-local-deploy
Apache Tomcat
from http
transform
S
e
r
v
i
c
e
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 possible
docker images
docker ps
OpenShift 3 CLI
●oc get services
OpenShift 3 CLI
●oc logs -f <pod-name>
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
●Demo
●Hello Service
●Create the Camel projects
●Docker
●OpenShift v3
●More Information
More information
●Apache Camel Microservices
●http://camel.apache.org/camel-boot
●Fabric8
●http://fabric8.io
●chat room #fabric8 on freenode
●Medium Fabric8 (blogs and videos)
●https://medium.com/fabric8-io