developing microservices with apache camel, by claus ibsen

68
Developing microservices with Apache Camel

Upload: judy-breedlove

Post on 12-Jan-2017

192 views

Category:

Software


1 download

TRANSCRIPT

Developing microservices

with Apache Camel

Atlanta 2011

https://devnexus.com

Claus Ibsen• Principal Software Engineer

at Red Hat

• Apache Camel8 years working with Camel

• Author of Camel in Action books

@davsclaus davsclaus

davsclaus.com

Java Developer

?

?or

Build a Camel Demo

Time

Source Code

https://github.com/davsclaus/fabric8-hello

Hello Service

Hello ServiceClient

Hello Service

Hello Service

Hello I am $HOSTNAME

Client

Implementation

Client Hello Service

HTTP

WildFySwarmSpring Boot WildFly Swarm

Implementation

Hello Service

Client Hello Service

HTTP

Implementation

Client Hello Service

HTTP

from timer to http

logfrom undertow

transform

hello service

Spring Boot Starter

Client

Type Safe Camel Editor

Cursor is here

http://fabric8.io/guide/forge.html

Type Safe Camel Editor

Type Safe Camel Editor

WildFly Swarm Generator

Hello Service

Hello Service

Ready to run local

Client Hello Service

HTTP 8080

from timer to netty

logfrom undertow

transform

hello service

How to build Docker Image?

Maven Project Docker Image

Docker Maven Plugin

Maven Project Fabric8 Maven Plugin Docker Imagebuild

https://maven.fabric8.io

Fabric8 Maven Plugin

https://maven.fabric8.io

Install fabric8-maven-plugin

mvn io.fabric8:fabric8-maven-plugin:3.1.63:setup

https://maven.fabric8.io

Fabric8 Maven Plugin

Build Docker Imagemvn package fabric8:build

Local Docker RepositoryHello Service

Client

Our Demo

Client Hello Service

http://localhost:8080

from timer to http

logfrom undertow

transform

hello service

Static vs Dynamic Platform

Client Hello Service

from timer to http

logfrom undertow

transform

hello service

Hardcoded hostname and port

http://localhost:8080

Dynamic Platform

Hello Service

service ip:port

Client

from timer to http

logfrom undertow

transform

hello service

Kubernetes Service

Kubernetes Service• Network Connection to one or more Pods

• Unique static IP and port (lifetime of service)

Kubernetes Service

service ip:port

from timer to http

logfrom undertow

transform

hello service

kube proxy

Kubernetes Master

enlisted on deployment

changes

pod

node

pod

node

Kubernetes Servicefrom user point of view

service ip:port

from timer to http

logfrom undertow

transform

hello service

pod pod

Out of the box serviceMaven artifactId

WildFly Swarm HTTP port

Service w/ Context Path• Annotate Service with Context-Path

/say is context-path

src/main/fabric8/service.yml

Custom Service

Container Port = Inside

Service Port = Outside

Service Name

src/main/fabric8/service.yml

Using Kubernetes Service

Client

from timer to http

log

We want to use hello service

How do we do that?

Using Kubernetes Service

• Environment Variables

• Hostname

• Port

Client

from timer to http

log

Service Discovery using DNS is available in newer versions of Kubernetes.

Service using ENV• Use ENV Client

from timer to http

log

Service using DNS• Use DNS Client

from timer to http

log

Ready to run in Kubernetes

Client Hello Service

{{service:helloswarm}}

from timer to netty

logfrom undertow

transform

hello service

kube proxy

How to deploy to Kubernetes?

Maven Project

How to deploy to Kubernetes?

Maven Project fabric8 Maven Plugin

run

Deploy - Hello Service

Hello Service

from undertow transform

hello service

• mvn fabric8:run mvn fabric8:deploy

Deploy - Client

• mvn fabric8:run mvn fabric8:deploy

Client

from timer to http

log

Debugging• Debugging Pods

mvn fabric8:debug

Remote Debug

Port 5005

Remote Debug

Breakpoint hit

Running Local Kubernetes/OpenShift

• Fabric8 Maven Plugin

• MiniKube

• MiniShift

• Vagrant

• OpenShift CDK

https://fabric8.io/guide/getStarted/index.html

Running fabric8• Download gofabric8 https://github.com/fabric8io/gofabric8/releases

• Start fabric8gofabric8 start --minishift --console --memory=2000

https://fabric8.io/guide/getStarted/minishift.html

Running fabric8

mvnio.fabric8:

fabric8-maven-plugin:3.1.63: cluster-start

-Dfabric8.cluster.kind=openshift

How I installed OpenShift

Installing is easy (even from a bar with a drink)

https://vimeo.com/185299147

fabric8 Web Console

minishift service fabric8

OpenShift CLI• oc get pods

You can also use CLI from docker &

kubernetes

OpenShift CLI• oc get service

OpenShift CLI• oc logs -f <pod name>

• minishift service helloswarm

Access Servicefrom your laptop

Scaling• Change deployment replicas

Scaling• Service load balancing

Load balancing is random

Error Handling• Client Side Redelivery

Error Handling• Client Side Circuit Breaker

Angry Pods

1st person shooter - Kill your pods

Free Book

http://developers.redhat.com/promotions/ microservices-for-java-developers/

Non Free Book

https://leanpub.com/camel-design-patterns

Non Free Book

https://www.packtpub.com/application-development/ apache-camel-developers-cookbook

Non Free Book

http://manning.com/ibsen2

Coupon code: camel39 gives 39% discount

Links• fabric8

• http://fabric8.io • Demo source code

• https://github.com/davsclaus/fabric8-hello • Try fabric8

• https://fabric8.io/guide/getStarted/minishift.html • Videos, blogs and more

• https://fabric8.io/community/index.html

@davsclaus davsclaus

davsclaus.com