71
WildFlies and a Camel Markus Eisele, @myfear Developer Advocate [email protected] May, 2015

WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container

  • Upload
    others

  • View
    9

  • Download
    0

Embed Size (px)

Citation preview

Page 1: WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container

WildFlies and a Camel

Markus Eisele, @myfearDeveloper [email protected], 2015

Page 2: WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container
Page 3: WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container
Page 4: WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container
Page 5: WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container
Page 6: WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container

camel.apache.org/eip

Page 7: WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container

Why Camel?

Page 8: WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container

• Open source integration library• Simple lightweight, use in any JVM or

application server• Connects to anything• 100s of components connecting to

databases, file systems, messaging systems, big data, SaaS providers, social media, ...

• Lots of tooling

Page 9: WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container

Camel Basics

Page 10: WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container

from  newOrderchoice

Page 11: WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container

from  newOrderchoice

when  isWidget to  widget

Page 12: WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container

from  newOrderchoice

when  isWidget to  widgetotherwise  to  theRest

Page 13: WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container

from  (newOrder)choice

when  (isWidget)  to  (widget)otherwise  to  (theRest)

Page 14: WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container

from  (newOrder).choice()

.when(isWidget).to(widget)

.otherwise().to(theRest);

Page 15: WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container

from  (newOrder).choice()

.when(isWidget).to(widget)

.otherwise().to(theRest);.end();

Endpoint  newOrder =  endpoint(“jms:incomming");Predicate  isWidget =  xpath("/order/product/type   =  'widget'");Endpoint  widget =  endpoint(“jms:widget");Endpoint  gadget =  endpoint(“jms:theRest");

Page 16: WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container

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(“jms:incomming");Predicate  isWidget =  xpath("/order/product/type  =  'widget'");Endpoint  widget =  endpoint(“jms:widget");Endpoint  gadget =  endpoint(“jms:theRest");

from(newOrder).choice().when(isWidget).to(widget).otherwise().to(theRest)

.end();}

}

Java

code

Page 17: WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container

Coool!

Page 18: WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container

import org.apache.camel.builder.RouteBuilder;

public  class MyRoute extends RouteBuilder {

public  void configure()  throws Exception  {

from("jms:incomming").choice().when(xpath("/order/product/type  =  'widget'"))

.to("jms:widget").otherwise().to("jms:theRest")

.end();}

}

Java

DSL

Page 19: WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container

<route><from  uri="jms:newOrder"  /><choice>

<when><xpath>/order/product/type='widget'</xpath><to  uri="jms:widget"/>

</when><otherwise>

<to  uri="jms:theRest"/></otherwise>

</choice></route>

XML D

SL

Page 20: WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container

Groo

vy DSL

import org.apache.camel.builder.RouteBuilder;

public  class MyRoute extends RouteBuilder {

public  void configure()  throws Exception  {

from("jms:incomming").choice().when({  it.in.header('zipcode')  ==~ /\d+/  })

.to("jms:widget").otherwise().to("jms:theRest")

}}

Page 21: WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container

Scala D

SL

class  FilterRoute {def createMyFilterRoute =  new  RouteBuilder {from("direct:start")

.filter(_.in("gold")  ==  "true").to("mock:gold")

}}

Page 22: WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container

import org.apache.camel.builder.RouteBuilder;

public  class MyRoute extends RouteBuilder {

public  void configure()  throws Exception  {

from("file:inbox/orders?delete=true").choice().when(xpath("/order/product/type  =  'widget'"))

.to("jms:widget").otherwise().to("jms:theRest")

.end();}

}

Endp

oint

s as UR

Is

Page 23: WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container
Page 24: WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container

http://camel.apache.org/component.html

150+ Components

Page 25: WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container

rest("/user").description("User  rest  service").consumes("application/json").produces("application/json")

.get("/{id}").description("Find  user  by  id").outType(User.class).to("bean:userService?method=getUser(${header.id})")

.put().description("Updates  or  create  a  user").type(User.class).to("bean:userService?method=updateUser")

.get("/findAll").description("Find  all  users").outTypeList(User.class).to("bean:userService?method=listUsers");

Page 26: WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container

http://blog.eisele.net/2014/12/camel-­‐on-­‐java-­‐ee-­‐7-­‐rest-­‐services-­‐swagger-­‐api-­‐doc.html

Page 27: WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container

http://camel.apache.org/data-­‐format.html

19 Data Formats

Page 28: WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container

//  lets  turn  Object  messages  into  json (Xstream)  then  send  to  MQSeries

from("activemq:My.Queue").marshal().json().to("mqseries:Another.Queue");

/**  Alternative  Librariesmarshal().json(JsonLibrary.Jackson)marshal().json(JsonLibrary.Gson).

**/

Page 29: WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container

http://camel.apache.org/languages.html

15 Expression Languages

Page 30: WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container

//  lets  route  if  a  line  item  is  over  $100from("queue:foo").filter(groovy("request.lineItems.any {  i -­‐>  i.value >  100  }")).to("queue:bar")

//  route  exchanges  from  admin  users  to  a  special  queue.from("direct:start")

.choice().when().javaScript("request.headers.get(&#39;user&#39;)  ==  &#39;admin&#39;")

.to("seda:adminQueue").otherwise().to("seda:regularQueue");

Page 31: WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container

Wow!

Page 32: WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container

• Integration Framework• Enterprise Integration Patterns (EIP)• Routing DSLs• Endpoint as URIs• Just Java or XML code (or even more)• No Container Dependency• A hell lot of ready made components• Expressions and Date-Formats

Page 33: WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container

FTW!

Page 34: WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container

Deploying Camel

Page 35: WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container

camel-core.jar = 2.8 MB!

Page 36: WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container

• Deployment Strategy• No Container Dependency• Lightweight & Embeddable

• Deployment Options• Standalone• WAR• Spring• Java EE• OSGi• Cloud

Page 37: WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container

• Containers• Apache ActiveMQ• Apache Karaf• Apache ServiceMix• Apache Tomcat• Fabric8• JBoss AS / WildFly• JBoss Fuse• JBoss Fuse Service Works• Jetty• WebLogic• Glassfish • WebSphere

Page 38: WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container

Camel & Java EE

Page 39: WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container

@Singleton@Startuppublic  class  Bootstrap  {

@InjectCdiCamelContext context;

@PostConstructpublic  void  init()  {

//  create  routes

//  Start  Camel  Contextcontext.start();

}

@PreDestroypublic  void  shutdown()  {

//  Graceful  Shutdown  Camel  Contextcontext.stop();

}

http://blog.eisele.net/2014/08/bootstrapping-­‐apache-­‐camel-­‐in-­‐java-­‐ee7.html

#1 Cam

el CDI

Page 40: WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container

• Not all components are working as expected• Deployment gets really large• Easy to run into classloading issues

Keep

in M

ind!

Page 41: WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container

#2 Cus

tom M

odule

https://sourcevirtues.wordpress.com/2013/11/25/add-­‐apache-­‐camel-­‐and-­‐spring-­‐as-­‐jboss-­‐module-­‐in-­‐wildfly/

• Create a Spring Module• Create a Camel Module

Page 42: WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container

• The module dependencies have to be correct.• Need to reference modules from

jboss-deployment-structure.xml• No pre-build list / no support

Keep

in M

ind!

Page 43: WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container

#3 Cam

el Sub

system

https://github.com/wildfly-­‐extras/wildfly-­‐camel

• Simply apply the wildfly-camel-patch to a compatible wildfly version

• wildflyext/wildfly-camel docker distribution

Page 44: WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container

• Not all components contained so far• Still under development• Growing component base

http://wildflyext.gitbooks.io/wildfly-­‐camel/content/

Keep

in M

ind!

Page 45: WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container

Camel and JavaEE

are awesome!

Page 46: WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container
Page 47: WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container

What users are telling us

Page 48: WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container

• Camel rocks in development• very easy to get started and create small projects• can I have more tooling?• need help scaling to 1000s of services and integration flows

• need help moving integration solutions through Continuous Deployment pipeline

Page 49: WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container

Something is missing

Page 50: WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container
Page 51: WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container

http://fabric8.io/

Page 52: WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container

• an open source integration platform• designed to make it easy to deploy, manage and scale integration solutions

• helps move integration solutions from dev -> test -> prod

Page 53: WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container

What does it do?

Page 54: WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container

• provision, configure and manage services

• perform incremental and rolling upgrades of changes

• discovery and load balancing of services• elastic scaling of services

Page 55: WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container

How does that look like?

Page 56: WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container

• 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 57: WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container

• 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 58: WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container

CamelApp

Configuration

Fabric8

Instance  1 App SpecConf

Instance  2 App SpecConf

Instance  3 App SpecConf

Instance  4 App SpecConf

Instance  … App SpecConf

Instance  n App SpecConf

Profile

DeveloperPC

Networking

Orchestration

Auto-­‐Scaling

Health  Checks

Console

Maven

Versioning

Deployment

Distribution

Page 59: WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container

• 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! • Will support OpenShift v3

Fabric8 V2

Page 60: WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container

V1 vs. V2• Profiles• Runtime Registry• Configuration

Repository• Tooling• Profiles

• Docker• Kubernetes

• PODs• Labels• Services• Apps

• App Zips• Builds

Page 61: WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container

http://camel.apache.org/download.html

http://www.jboss.org/products/devstudio/overview/

Downloa

d and

install

http://fabric8.io/v2/

Page 62: WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container
Page 63: WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container

Wanna know more ?

Page 64: WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container

http://camel.apache.org/examples

Page 65: WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container
Page 66: WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container

http://camel.apache.org/mailing-lists.html

http://stackoverflow.com/questions/tagged/apache-camel

http://camel.apache.org/irc-room.html

http://fabric8.io/v2/

Page 67: WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container

What else ?

Page 68: WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container

http://camel.apache.org/commercial-­‐camel-­‐offerings.html

+

Page 69: WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container

http://bit.ly/virtualJBUG@vJBUG

Page 70: WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container
Page 71: WildFliesand a Camel · • Integration Framework • Enterprise Integration Patterns (EIP) • Routing DSLs • Endpoint as URIs • Just Java or XML code (or even more) • No Container