microservices with apache camel, docker and fabric8 v2
TRANSCRIPT
#microservices with Apache Camel, Docker and Fabric8v2
Christian PostaPrincipal Middleware Specialist/Architect
Blog: http://blog.christianposta.com
Twitter: @christianposta
Email: [email protected]
• Committer on Apache Camel, Apache ActiveMQ, Fabric8
• Recovering consultant
• Spent lot of time working with one of the largest Microservices, web-
scale, unicorn companies
• Frequent blogger and speaker about open-source, cloud, and
microservices
• Microservices: the good, the bad
• Do you even need integration?
• Real developers ride Camels
• Microservices the Docker way with
Fabric8
• Questions / Demo
Agenda
Microservices: the good, the bad
• Agile• SOA principles• Domain Driven Design• Hexagonal Architectures• Pipes and Filters• Actor Model• SEDA
Microservices not really new, per-se
A way to organize teams that mimic the
structure of an organization for greater
autonomy and reduced cross-team
synchronization for the purposes of scalability,
faster solution delivery, and ability to manage
complexity at the expense of known tradeoffs.
So what is “Microservices”?
• Faster software delivery
• Potential for faster innovation
• Scale easier
• Right technology stack for the problem
• Grok services easier
• Test individual services easier
• Individual deployments
• System complexity
• Operational complexity
• Testing is harder across services
• Security
• It’s freakin hard
• Resource overhead
• Network overhead
• Lack of tooling
Drawbacks
1. Do you have a scaling problem?
2. You need to deliver software much faster?
3. Do you have organizational complexity?
When do you do microservices:
• Understanding of modularity, API design
• Small, cross-functional teams (pizza box)
• Self service access to infrastructure
• Strong automation capabilities
• Mature CI/CD practices
Foundations of Microservices
Do YOU want to do Microservices?
Microservices Envy: http://www.thoughtworks.com/radar/techniques/microservice-envy
You’re not going to do microserviceshttp://christianposta.com/blog/not-gonna-happen
Do you even need integration?
Yes.
17
Enterprise Service Bus?
Hexagonal architecture
Microservices
Real developers ride Camels
Real developers ride Camels!
Heavy Lifting: Camel for Microservices
• Dynamic routing options
• REST DSL
• Backpressure mechanisms
• Circuit Breaker
Heavy Lifting: Camel for Microservices
• “Smart endpoints, dumb pipes”• Endpoint does one thing well • Metadata used for further routing• Really “dynamic” with rules engine (eg,
Drools/BRMS)
Dynamic Routing
REST DSL
public 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”); }}
• 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
Circuit breaker
public class OrderProcessorRouteBuilder extends RouteBuilder {
@Override public void configure() throws Exception {
from(“direct:someinterface”) .loadbalance()
.circuitBreaker(3, 20000L, MyException.class)
.to(“ibatis:storeOrder?statementType=Insert”); }}
More Information
Microservices the Docker way with Fabric8
• 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
• Implemented with Docker and Kubernetes• Use any JVM (or any technology)• Docker images, encourage immutable, well-
defined, well-tested deployments• Provides networking, JVM isolation,
orchestration, auto-scaling, health checks, cloud deployments
Fabric8 V2
• Docker for packaging• Docker/linux containers for process isolation• Kubernetes for container orchestration (start,
stop, health check, replicas, service discovery)• Set of microservices/apps for
• Management• Continuous Delivery• Integration (iPaaS)
• Tools for Java Developers
Fabric8 V2
• Console• Docker Maven Plugin• Fabric8 Maven Plugin• Dependency Injection (of Kube services too!)
• Spring• CDI
• Java Libraries• Kubernetes fluent API• Arquillian plugins • Kubernetes Jolokia
Fabric8 V2