Real world #microservices with Apache Camel, Fabric8, and OpenShift
Transcript of Real world #microservices with Apache Camel, Fabric8, and OpenShift
![Page 1: Real world #microservices with Apache Camel, Fabric8, and OpenShift](https://reader034.fdocuments.in/reader034/viewer/2022052316/55a6b8071a28ab666b8b45f2/html5/thumbnails/1.jpg)
Real-world #microservices
with Apache Camel and
Fabric8
![Page 2: Real world #microservices with Apache Camel, Fabric8, and OpenShift](https://reader034.fdocuments.in/reader034/viewer/2022052316/55a6b8071a28ab666b8b45f2/html5/thumbnails/2.jpg)
![Page 3: Real world #microservices with Apache Camel, Fabric8, and OpenShift](https://reader034.fdocuments.in/reader034/viewer/2022052316/55a6b8071a28ab666b8b45f2/html5/thumbnails/3.jpg)
Who?Christian Posta
Principal Middleware Specialist/Architect
Blog: http://christianposta.com/blog
Twitter: @christianposta
Email: [email protected]
• Committer on Apache Camel, ActiveMQ, Fabric8, PMC on ActiveMQ
• Author: Essential Camel Components DZone Refcard
• Frequent blogger and speaker about open-source technology!
![Page 4: Real world #microservices with Apache Camel, Fabric8, and OpenShift](https://reader034.fdocuments.in/reader034/viewer/2022052316/55a6b8071a28ab666b8b45f2/html5/thumbnails/4.jpg)
• Microservices
• Heavy lifting with Apache Camel
• Managing microservices with Fuse,
Fabric8 v1
• OpenShift, Fabric8 v2
• Beer (lots?)
Agenda
![Page 5: Real world #microservices with Apache Camel, Fabric8, and OpenShift](https://reader034.fdocuments.in/reader034/viewer/2022052316/55a6b8071a28ab666b8b45f2/html5/thumbnails/5.jpg)
Why do we care?
![Page 6: Real world #microservices with Apache Camel, Fabric8, and OpenShift](https://reader034.fdocuments.in/reader034/viewer/2022052316/55a6b8071a28ab666b8b45f2/html5/thumbnails/6.jpg)
![Page 7: Real world #microservices with Apache Camel, Fabric8, and OpenShift](https://reader034.fdocuments.in/reader034/viewer/2022052316/55a6b8071a28ab666b8b45f2/html5/thumbnails/7.jpg)
![Page 8: Real world #microservices with Apache Camel, Fabric8, and OpenShift](https://reader034.fdocuments.in/reader034/viewer/2022052316/55a6b8071a28ab666b8b45f2/html5/thumbnails/8.jpg)
![Page 9: Real world #microservices with Apache Camel, Fabric8, and OpenShift](https://reader034.fdocuments.in/reader034/viewer/2022052316/55a6b8071a28ab666b8b45f2/html5/thumbnails/9.jpg)
Micro what?
![Page 10: Real world #microservices with Apache Camel, Fabric8, and OpenShift](https://reader034.fdocuments.in/reader034/viewer/2022052316/55a6b8071a28ab666b8b45f2/html5/thumbnails/10.jpg)
![Page 11: Real world #microservices with Apache Camel, Fabric8, and OpenShift](https://reader034.fdocuments.in/reader034/viewer/2022052316/55a6b8071a28ab666b8b45f2/html5/thumbnails/11.jpg)
• Services, reuse, composition
• Loose coupling!
• Contracts
• Incremental change
• “Business Agility”
SOA!
![Page 12: Real world #microservices with Apache Camel, Fabric8, and OpenShift](https://reader034.fdocuments.in/reader034/viewer/2022052316/55a6b8071a28ab666b8b45f2/html5/thumbnails/12.jpg)
![Page 13: Real world #microservices with Apache Camel, Fabric8, and OpenShift](https://reader034.fdocuments.in/reader034/viewer/2022052316/55a6b8071a28ab666b8b45f2/html5/thumbnails/13.jpg)
SOA made smaller… micro even…
So what are microservices?
![Page 14: Real world #microservices with Apache Camel, Fabric8, and OpenShift](https://reader034.fdocuments.in/reader034/viewer/2022052316/55a6b8071a28ab666b8b45f2/html5/thumbnails/14.jpg)
A term that helps describe distributed systems
that organically evolve into scalable, loosely
coupled, modular sets of services that work
together to deliver business value
with acceptable tradeoffs.
So what are microservices?
![Page 15: Real world #microservices with Apache Camel, Fabric8, and OpenShift](https://reader034.fdocuments.in/reader034/viewer/2022052316/55a6b8071a28ab666b8b45f2/html5/thumbnails/15.jpg)
• If my services are isolated at the
process level, I’m doing
#microservices
• If I use REST/Thrift/ProtoBuf
instead of SOAP, I’m doing
#microservices
• If I use JSON, I’m doing
#microservices
• If I use no-container / SpringBoot
/ Dropwizard / embedded Jetty,
I’m doing #microservices
I’m doing microservices if…
![Page 16: Real world #microservices with Apache Camel, Fabric8, and OpenShift](https://reader034.fdocuments.in/reader034/viewer/2022052316/55a6b8071a28ab666b8b45f2/html5/thumbnails/16.jpg)
• Agile methodology
• SOA principles
• Domain Driven Design
• Hexagonal Architectures
• Pipes and Filters
• Actor Model
• REST
• SEDA
Microservices emerged as a result…
![Page 17: Real world #microservices with Apache Camel, Fabric8, and OpenShift](https://reader034.fdocuments.in/reader034/viewer/2022052316/55a6b8071a28ab666b8b45f2/html5/thumbnails/17.jpg)
• Modularity!
• Flexible technology options
• “Smart endpoints” “dumb pipes”
• Evolving design
• Independently scalable
• Automation, DevOps philosophy
• Decentralized, choreographed interactions
• Testable
• Design for failure
Microservices…
![Page 18: Real world #microservices with Apache Camel, Fabric8, and OpenShift](https://reader034.fdocuments.in/reader034/viewer/2022052316/55a6b8071a28ab666b8b45f2/html5/thumbnails/18.jpg)
Isolation: logical or physical?
![Page 19: Real world #microservices with Apache Camel, Fabric8, and OpenShift](https://reader034.fdocuments.in/reader034/viewer/2022052316/55a6b8071a28ab666b8b45f2/html5/thumbnails/19.jpg)
• No silver bullet; distributed systems are
*hard*
• Dependency hell, custom shared libraries
• Fragmented and inconsistent management
• Team communication challenges
• Health checking, monitoring, liveness
• Over architecting, performance concerns,
things spiraling out of control fast
Challenges ahead…
![Page 20: Real world #microservices with Apache Camel, Fabric8, and OpenShift](https://reader034.fdocuments.in/reader034/viewer/2022052316/55a6b8071a28ab666b8b45f2/html5/thumbnails/20.jpg)
Apache Camel for
microservices?
![Page 21: Real world #microservices with Apache Camel, Fabric8, and OpenShift](https://reader034.fdocuments.in/reader034/viewer/2022052316/55a6b8071a28ab666b8b45f2/html5/thumbnails/21.jpg)
Real developers ride Camels!
![Page 22: Real world #microservices with Apache Camel, Fabric8, and OpenShift](https://reader034.fdocuments.in/reader034/viewer/2022052316/55a6b8071a28ab666b8b45f2/html5/thumbnails/22.jpg)
2
2
Apache CamelApache Camel is an open-source,
light-weight, integration library.
Use Camel to integrate disparate systems
that speak different protocols and data formats
![Page 23: Real world #microservices with Apache Camel, Fabric8, and OpenShift](https://reader034.fdocuments.in/reader034/viewer/2022052316/55a6b8071a28ab666b8b45f2/html5/thumbnails/23.jpg)
Apache Camel
Enterprise Integration Patterns
http://camel.apache.org/eip
![Page 24: Real world #microservices with Apache Camel, Fabric8, and OpenShift](https://reader034.fdocuments.in/reader034/viewer/2022052316/55a6b8071a28ab666b8b45f2/html5/thumbnails/24.jpg)
Features
● Enterprise Integration Patterns (EIPs)
● Domain Specific Language to write “flows” or “routes”
● Large collection of adapters/components for legacy
systems, B2B, and SaaS
● Strong Unit test/Integration test framework
● Expression languages
● Data Formats
● Tooling with JBoss Developer Studio
![Page 25: Real world #microservices with Apache Camel, Fabric8, and OpenShift](https://reader034.fdocuments.in/reader034/viewer/2022052316/55a6b8071a28ab666b8b45f2/html5/thumbnails/25.jpg)
Java DSLpublic class OrderProcessorRouteBuilder extends RouteBuilder {
@Override
public void configure() throws Exception {
from(“activemq:orders”)
.choice()
.when(header(“customer-rating”).isEqualTo(“gold”))
.to(“ibmmq:topic:specialCustomer”)
.otherwise()
.to(“ftp://user@host/orders/regularCustomers”)
.end()
.log(“received new order ${body.orderId}”)
.to(“ibatis:storeOrder?statementType=Insert”);
}
}
![Page 26: Real world #microservices with Apache Camel, Fabric8, and OpenShift](https://reader034.fdocuments.in/reader034/viewer/2022052316/55a6b8071a28ab666b8b45f2/html5/thumbnails/26.jpg)
Spring XML DSL<route id=“processOrders”>
<from uri=“activemq:orders”/>
<choice>
<when>
<simple>${header.customer-rating} == ‘gold’</simple>
<to uri=“wmq:topic:specialCustomer”>
</when>
<otherwise>
<to uri=“ftp://user@host/orders/regularCustomers” />
</otherwise>
</choice>
<log message=“received new order ${body.orderId}”/>
<to uri=“ibatis:storeOrder?statementType=Insert”/>
</route>
![Page 27: Real world #microservices with Apache Camel, Fabric8, and OpenShift](https://reader034.fdocuments.in/reader034/viewer/2022052316/55a6b8071a28ab666b8b45f2/html5/thumbnails/27.jpg)
Camel - JBoss Developer Studio
![Page 28: Real world #microservices with Apache Camel, Fabric8, and OpenShift](https://reader034.fdocuments.in/reader034/viewer/2022052316/55a6b8071a28ab666b8b45f2/html5/thumbnails/28.jpg)
• Dynamic routing options
• REST DSL
• Backpressure mechanisms
• Loadbalancing algorithms / Circuit Breaker
pattern
Heavy Lifting: Camel for Microservices
![Page 29: Real world #microservices with Apache Camel, Fabric8, and OpenShift](https://reader034.fdocuments.in/reader034/viewer/2022052316/55a6b8071a28ab666b8b45f2/html5/thumbnails/29.jpg)
• “Smart endpoints, dumb pipes”
• Endpoint does one thing well
• Metadata used for further routing
• Really “dynamic” with rules engine (eg,
Drools/BRMS)
Dynamic Routing
![Page 30: Real world #microservices with Apache Camel, Fabric8, and OpenShift](https://reader034.fdocuments.in/reader034/viewer/2022052316/55a6b8071a28ab666b8b45f2/html5/thumbnails/30.jpg)
• Content Based Router
• Dynamic Router
• Routing Slip
• Recipient List
Dynamic Routing
![Page 31: Real world #microservices with Apache Camel, Fabric8, and OpenShift](https://reader034.fdocuments.in/reader034/viewer/2022052316/55a6b8071a28ab666b8b45f2/html5/thumbnails/31.jpg)
• Expressive way to define REST endpoints
• POST, REST, PUT
• Auto binding to POJOs
• Plugs into Swagger for interface
definition/documentation
• Uses configurable HTTP engine• camel-netty-http
• camel-jetty
• camel-reslet
• camel-sevlet (deploy into other containers)
• camel-spark-rest
REST DSL (2.14)
![Page 32: Real world #microservices with Apache Camel, Fabric8, and OpenShift](https://reader034.fdocuments.in/reader034/viewer/2022052316/55a6b8071a28ab666b8b45f2/html5/thumbnails/32.jpg)
REST DSLpublic class OrderProcessorRouteBuilder extends RouteBuilder {
@Override
public void configure() throws Exception {
rest().post(“/order/socks”)
.description(“New Order for pair of socks”)
.consumes(“application/json”)
.route()
.to(“activemq:topic:newOrder”)
.log(“received new order ${body.orderId}”)
.to(“ibatis:storeOrder?statementType=Insert”);
}
}
![Page 33: Real world #microservices with Apache Camel, Fabric8, and OpenShift](https://reader034.fdocuments.in/reader034/viewer/2022052316/55a6b8071a28ab666b8b45f2/html5/thumbnails/33.jpg)
• Backpressure is a way for a service to flow
control callers
• Detecting when can be difficult
• Need to bound processing queues in a
SEDA
• Take advantage of built in TCP flow control
for socket/http requests
Backpressure with Camel
![Page 34: Real world #microservices with Apache Camel, Fabric8, and OpenShift](https://reader034.fdocuments.in/reader034/viewer/2022052316/55a6b8071a28ab666b8b45f2/html5/thumbnails/34.jpg)
• Throttle EIP• http://camel.apache.org/throttler.html
• Blocking SEDA Queue
• from(“seda:name?size=100&blockWhenFull=true)
• Configure jetty/netty to use blocking acceptor
queues
• https://wiki.eclipse.org/Jetty/Howto/High_Load
• Using Exception handling/retry and DLQ
logic when getting flow controlled• http://camel.apache.org/error-handling-in-camel.html
Backpressure with Camel
![Page 35: Real world #microservices with Apache Camel, Fabric8, and OpenShift](https://reader034.fdocuments.in/reader034/viewer/2022052316/55a6b8071a28ab666b8b45f2/html5/thumbnails/35.jpg)
• Useful to keep from overloading a system
(use in conjunction with backpressure if you
can)
• Smart loadbalancing• Sticky
• Random
• Failover
• Circuit breaker
Loadbalance/Circuit breaker
![Page 36: Real world #microservices with Apache Camel, Fabric8, and OpenShift](https://reader034.fdocuments.in/reader034/viewer/2022052316/55a6b8071a28ab666b8b45f2/html5/thumbnails/36.jpg)
Circuit breaker
Image from http://martinfowler.com/bliki/CircuitBreaker.html
![Page 37: Real world #microservices with Apache Camel, Fabric8, and OpenShift](https://reader034.fdocuments.in/reader034/viewer/2022052316/55a6b8071a28ab666b8b45f2/html5/thumbnails/37.jpg)
Circuit breakerpublic class OrderProcessorRouteBuilder extends RouteBuilder {
@Override
public void configure() throws Exception {
from(“direct:someinterface”)
.loadbalance()
.circuitBreaker(3, 20000L, MyException.class)
.to(“ibatis:storeOrder?statementType=Insert”);
}
}
![Page 38: Real world #microservices with Apache Camel, Fabric8, and OpenShift](https://reader034.fdocuments.in/reader034/viewer/2022052316/55a6b8071a28ab666b8b45f2/html5/thumbnails/38.jpg)
More Information● Camel in Action
● Apache Camel Developer’s Cookbook
● Community website
○ http://camel.apache.org/
![Page 39: Real world #microservices with Apache Camel, Fabric8, and OpenShift](https://reader034.fdocuments.in/reader034/viewer/2022052316/55a6b8071a28ab666b8b45f2/html5/thumbnails/39.jpg)
JBoss Fuse (Red Hat
product)
![Page 40: Real world #microservices with Apache Camel, Fabric8, and OpenShift](https://reader034.fdocuments.in/reader034/viewer/2022052316/55a6b8071a28ab666b8b45f2/html5/thumbnails/40.jpg)
![Page 41: Real world #microservices with Apache Camel, Fabric8, and OpenShift](https://reader034.fdocuments.in/reader034/viewer/2022052316/55a6b8071a28ab666b8b45f2/html5/thumbnails/41.jpg)
RED HAT JBOSS FUSE
Development and tooling
Develop, test, debug, refine,
deploy
JBoss Developer Studio
Web services frameworkWeb services standards, SOAP,
XML/HTTP, RESTful HTTP
Integration frameworkTransformation, mediation, enterprise
integration patterns
Management and
monitoring
System and web services metrics,
automated discovery, container
status, automatic updates
JBoss Operations Network
+
JBoss Fabric Management
Console
(hawtio)
Apache CXF Apache Camel
Reliable MessagingJMS/STOMP/NMS/MQTT, publishing-subscribe/point-2-point, store and forward
Apache ActiveMQ
ContainerLife cycle management, resource management, dynamic deployment,
security and provisioning
Apache Karaf + Fuse Fabric
RED HAT ENTERPRISE LINUXWindows, UNIX, and other Linux
![Page 42: Real world #microservices with Apache Camel, Fabric8, and OpenShift](https://reader034.fdocuments.in/reader034/viewer/2022052316/55a6b8071a28ab666b8b45f2/html5/thumbnails/42.jpg)
Managing microservice
deployments
![Page 43: Real world #microservices with Apache Camel, Fabric8, and OpenShift](https://reader034.fdocuments.in/reader034/viewer/2022052316/55a6b8071a28ab666b8b45f2/html5/thumbnails/43.jpg)
![Page 44: Real world #microservices with Apache Camel, Fabric8, and OpenShift](https://reader034.fdocuments.in/reader034/viewer/2022052316/55a6b8071a28ab666b8b45f2/html5/thumbnails/44.jpg)
![Page 45: Real world #microservices with Apache Camel, Fabric8, and OpenShift](https://reader034.fdocuments.in/reader034/viewer/2022052316/55a6b8071a28ab666b8b45f2/html5/thumbnails/45.jpg)
• Simplifies deployments
• Provides centralized configuration
• Versioning
• Visualization of your middleware
• Service discovery
• Smart load balancing
• Failover
• Provides cluster capabilities, coordination
http://fabric8.io
![Page 46: Real world #microservices with Apache Camel, Fabric8, and OpenShift](https://reader034.fdocuments.in/reader034/viewer/2022052316/55a6b8071a28ab666b8b45f2/html5/thumbnails/46.jpg)
• Implemented with Zookeeper and git
• Intended to be used with a dynamic
JVM/Apache Karaf
• Profiles store configuration, metadata, end-
state deployments
• Networking, JVM isolation, orchestration,
auto-scaling, health checks, cloud
deployments: all up to you
Fabric8 V1.x
![Page 47: Real world #microservices with Apache Camel, Fabric8, and OpenShift](https://reader034.fdocuments.in/reader034/viewer/2022052316/55a6b8071a28ab666b8b45f2/html5/thumbnails/47.jpg)
• Registry• Where configs are stored, everything centrally
managed
• Profiles• Description of end-state deployment of a server
• Agent
• Listens on the server that can respond to registry
changes/profile updates
Fabric8 V1.x
![Page 48: Real world #microservices with Apache Camel, Fabric8, and OpenShift](https://reader034.fdocuments.in/reader034/viewer/2022052316/55a6b8071a28ab666b8b45f2/html5/thumbnails/48.jpg)
Quick Demo V1
![Page 49: Real world #microservices with Apache Camel, Fabric8, and OpenShift](https://reader034.fdocuments.in/reader034/viewer/2022052316/55a6b8071a28ab666b8b45f2/html5/thumbnails/49.jpg)
• Implemented with Docker and Kubernetes
• Use any JVM (or any technology)
• Docker images, encourage static, well-
defined, well-tested deployments
• Provides networking, JVM isolation,
orchestration, auto-scaling, health checks,
cloud deployments
• Still in community! Proving this out!
Fabric8 V2
![Page 50: Real world #microservices with Apache Camel, Fabric8, and OpenShift](https://reader034.fdocuments.in/reader034/viewer/2022052316/55a6b8071a28ab666b8b45f2/html5/thumbnails/50.jpg)
Docker / Linux Containers
![Page 51: Real world #microservices with Apache Camel, Fabric8, and OpenShift](https://reader034.fdocuments.in/reader034/viewer/2022052316/55a6b8071a28ab666b8b45f2/html5/thumbnails/51.jpg)
How different than VMs?
![Page 52: Real world #microservices with Apache Camel, Fabric8, and OpenShift](https://reader034.fdocuments.in/reader034/viewer/2022052316/55a6b8071a28ab666b8b45f2/html5/thumbnails/52.jpg)
![Page 53: Real world #microservices with Apache Camel, Fabric8, and OpenShift](https://reader034.fdocuments.in/reader034/viewer/2022052316/55a6b8071a28ab666b8b45f2/html5/thumbnails/53.jpg)
Kubernetes
![Page 54: Real world #microservices with Apache Camel, Fabric8, and OpenShift](https://reader034.fdocuments.in/reader034/viewer/2022052316/55a6b8071a28ab666b8b45f2/html5/thumbnails/54.jpg)
![Page 55: Real world #microservices with Apache Camel, Fabric8, and OpenShift](https://reader034.fdocuments.in/reader034/viewer/2022052316/55a6b8071a28ab666b8b45f2/html5/thumbnails/55.jpg)
• Pods
• Services
• Replication Controllers
Kubernetes
![Page 56: Real world #microservices with Apache Camel, Fabric8, and OpenShift](https://reader034.fdocuments.in/reader034/viewer/2022052316/55a6b8071a28ab666b8b45f2/html5/thumbnails/56.jpg)
Red Hat’s PaaS: OpenShift
Public
PaaS
Service
On-premise
or Private
PaaS
Software
Open
Source
PaaS
Project
![Page 57: Real world #microservices with Apache Camel, Fabric8, and OpenShift](https://reader034.fdocuments.in/reader034/viewer/2022052316/55a6b8071a28ab666b8b45f2/html5/thumbnails/57.jpg)
Scale IT Like a Factory with PaaS
![Page 58: Real world #microservices with Apache Camel, Fabric8, and OpenShift](https://reader034.fdocuments.in/reader034/viewer/2022052316/55a6b8071a28ab666b8b45f2/html5/thumbnails/58.jpg)
Quick Demo V2
![Page 59: Real world #microservices with Apache Camel, Fabric8, and OpenShift](https://reader034.fdocuments.in/reader034/viewer/2022052316/55a6b8071a28ab666b8b45f2/html5/thumbnails/59.jpg)
Demo and Questions