real world #microservices with apache camel, fabric8, and openshift

59
Real-world #microservices with Apache Camel and Fabric8

Upload: ceposta

Post on 16-Jul-2015

1.391 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Real world #microservices with Apache Camel, Fabric8, and OpenShift

Real-world #microservices

with Apache Camel and

Fabric8

Page 2: Real world #microservices with Apache Camel, Fabric8, and OpenShift
Page 3: Real world #microservices with Apache Camel, Fabric8, and OpenShift

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

• 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

Why do we care?

Page 6: Real world #microservices with Apache Camel, Fabric8, and OpenShift
Page 7: Real world #microservices with Apache Camel, Fabric8, and OpenShift
Page 8: Real world #microservices with Apache Camel, Fabric8, and OpenShift
Page 9: Real world #microservices with Apache Camel, Fabric8, and OpenShift

Micro what?

Page 10: Real world #microservices with Apache Camel, Fabric8, and OpenShift
Page 11: Real world #microservices with Apache Camel, Fabric8, and OpenShift

• Services, reuse, composition

• Loose coupling!

• Contracts

• Incremental change

• “Business Agility”

SOA!

Page 12: Real world #microservices with Apache Camel, Fabric8, and OpenShift
Page 13: Real world #microservices with Apache Camel, Fabric8, and OpenShift

SOA made smaller… micro even…

So what are microservices?

Page 14: Real world #microservices with Apache Camel, Fabric8, and OpenShift

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

• 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

• 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

• 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

Isolation: logical or physical?

Page 19: Real world #microservices with Apache Camel, Fabric8, and OpenShift

• 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

Apache Camel for

microservices?

Page 21: Real world #microservices with Apache Camel, Fabric8, and OpenShift

Real developers ride Camels!

Page 22: Real world #microservices with Apache Camel, Fabric8, and OpenShift

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

Apache Camel

Enterprise Integration Patterns

http://camel.apache.org/eip

Page 24: Real world #microservices with Apache Camel, Fabric8, and OpenShift

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

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

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

Camel - JBoss Developer Studio

Page 28: Real world #microservices with Apache Camel, Fabric8, and OpenShift

• 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

• “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

• Content Based Router

• Dynamic Router

• Routing Slip

• Recipient List

Dynamic Routing

Page 31: Real world #microservices with Apache Camel, Fabric8, and OpenShift

• 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

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

• 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

• 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

• 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

Circuit breaker

Image from http://martinfowler.com/bliki/CircuitBreaker.html

Page 37: Real world #microservices with Apache Camel, Fabric8, and OpenShift

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

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

JBoss Fuse (Red Hat

product)

Page 40: Real world #microservices with Apache Camel, Fabric8, and OpenShift
Page 41: Real world #microservices with Apache Camel, Fabric8, and OpenShift

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

Managing microservice

deployments

Page 43: Real world #microservices with Apache Camel, Fabric8, and OpenShift
Page 44: Real world #microservices with Apache Camel, Fabric8, and OpenShift
Page 45: Real world #microservices with Apache Camel, Fabric8, and OpenShift

• 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

• 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

• 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

Quick Demo V1

Page 49: Real world #microservices with Apache Camel, Fabric8, and OpenShift

• 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

Docker / Linux Containers

Page 51: Real world #microservices with Apache Camel, Fabric8, and OpenShift

How different than VMs?

Page 52: Real world #microservices with Apache Camel, Fabric8, and OpenShift
Page 53: Real world #microservices with Apache Camel, Fabric8, and OpenShift

Kubernetes

Page 54: Real world #microservices with Apache Camel, Fabric8, and OpenShift
Page 55: Real world #microservices with Apache Camel, Fabric8, and OpenShift

• Pods

• Services

• Replication Controllers

Kubernetes

Page 56: Real world #microservices with Apache Camel, Fabric8, and OpenShift

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

Scale IT Like a Factory with PaaS

Page 58: Real world #microservices with Apache Camel, Fabric8, and OpenShift

Quick Demo V2

Page 59: Real world #microservices with Apache Camel, Fabric8, and OpenShift

Demo and Questions