Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

ApacheCon EU 2016 - Apache Camel the integration library

1,249 views

Published on

This presentation will demonstrate to developers involved with integration how the Apache Camel project can make your life much easier.

We start with an introduction to what Apache Camel is, and how you can use Camel to make integration much easier. Allowing you to focus on your business logic, rather than low level messaging protocols, and transports.

You will hear how Apache Camel is related Enterprise Integration Patterns which you can use in your architectural designs and as well in Java or XML code, running on the JVM with Camel.

You will also hear what other features Camel provides out of the box, which can make integration much easier for you.

Published in: Internet

ApacheCon EU 2016 - Apache Camel the integration library

  1. 1. Apache Camel The Integration Library EU 2016 Claus Ibsen
  2. 2. Claus Ibsen • Senior Principal Software Engineer at Red Hat • Apache Camel 8+ years commiter and PMC member • Author of Camel in Action books @davsclaus davsclaus davsclaus.com claus.ibsen@gmail.com
  3. 3. Agenda • What is Apache Camel? • Little Example • Trying Apache Camel • What's in the Camel Box? • Running Camel • More Information
  4. 4. What is Apache Camel? • Quote from the website Apache Camel is a powerful Open Source Integration Framework based on Enterprise Integration Patterns
  5. 5. What is Apache Camel? • Quote from the website Apache Camel is a powerful Open Source Integration Framework based on Enterprise Integration Patterns
  6. 6. Integration Framework
  7. 7. Enterprise Integration Patterns
  8. 8. Enterprise Integration Patterns
  9. 9. Content Based Router
  10. 10. Content Based Router from newOrder
  11. 11. Content Based Router from newOrder choice
  12. 12. Content Based Router from newOrder choice when isWidget to widget
  13. 13. Content Based Router from newOrder choice when isWidget to widget otherwise to gadget
  14. 14. Content Based Router from(newOrder) choice when(isWidget) to(widget) otherwise to(gadget)
  15. 15. Content Based Router from(newOrder) .choice() .when(isWidget).to(widget) .otherwise().to(gadget);
  16. 16. Content Based Router Endpoint newOrder = endpoint("activemq:queue:newOrder"); from(newOrder) .choice() .when(isWidget).to(widget) .otherwise().to(gadget);
  17. 17. Content Based Router Endpoint newOrder = endpoint("activemq:queue:newOrder"); Predicate isWidget = xpath("/order/product = 'widget'"); from(newOrder) .choice() .when(isWidget).to(widget) .otherwise().to(gadget);
  18. 18. Content Based Router Endpoint newOrder = endpoint("activemq:queue:newOrder"); Predicate isWidget = xpath("/order/product = 'widget'"); Endpoint widget = endpoint("activemq:queue:widget"); Endpoint gadget = endpoint("activemq:queue:gadget"); from(newOrder) .choice() .when(isWidget).to(widget) .otherwise().to(gadget);
  19. 19. Java Code public void configure() throws Exception { Endpoint newOrder = endpoint("activemq:queue:newOrder"); Predicate isWidget = xpath("/order/product = 'widget'"); Endpoint widget = endpoint("activemq:queue:widget"); Endpoint gadget = endpoint("activemq:queue:gadget"); from(newOrder) .choice() .when(isWidget).to(widget) .otherwise().to(gadget); }
  20. 20. Java Code 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("activemq:queue:newOrder"); Predicate isWidget = xpath("/order/product = 'widget'"); Endpoint widget = endpoint("activemq:queue:widget"); Endpoint gadget = endpoint("activemq:queue:gadget"); from(newOrder) .choice() .when(isWidget).to(widget) .otherwise().to(gadget); } }
  21. 21. Java DSL import org.apache.camel.builder.RouteBuilder; public class MyRoute extends RouteBuilder { public void configure() throws Exception { from("activemq:queue:newOrder") .choice() .when(xpath("/order/product = 'widget'")) .to("activemq:queue:widget") .otherwise() .to("activemq:queue:gadget"); } }
  22. 22. XML DSL <route> <from uri="activemq:queue:newOrder"/> <choice> <when> <xpath>/order/product = 'widget'</xpath> <to uri="activemq:queue:widget"/> </when> <otherwise> <to uri="activemq:queue:gadget"/> </otherwise> </choice> </route>
  23. 23. Endpoint URIs <route> <from uri="file:inbox/orders"/> <choice> <when> <xpath>/order/product = 'widget'</xpath> <to uri="activemq:queue:widget"/> </when> <otherwise> <to uri="activemq:queue:gadget"/> </otherwise> </choice> </route> Use file instead
  24. 24. Endpoint URIs <route> <from uri="file:inbox/orders?delete=true"/> <choice> <when> <xpath>/order/product = 'widget'</xpath> <to uri="activemq:queue:widget"/> </when> <otherwise> <to uri="activemq:queue:gadget"/> </otherwise> </choice> </route> Parameters
  25. 25. Just Java Code
  26. 26. Just XML
  27. 27. Architecture
  28. 28. Components ahc bindy coap docker ahc-ws blueprint cometd dozer apns boon context dropbox atmosphere box couchdb eclipse atom cache crypto ejb aws cassandraql csv elasticsearch bam castor cfx elsql bean-validator cdi cxf-transport eventadmin beanio chunk disruptor exec beanstalk cmis dns facebook
  29. 29. Components flatpack google-drive hbase jacksonxml fop google-mail hdfs jasypt freemarker gora hdfs2 javaspace ftp grape http jaxb gae groovy http4 jbpm ganglia gson ibatis jclouds geocoder guava-eventbus ical jcr git guice infinispan jdbc github hawtdb irc jetty8 google-calendar hazelcast jackson jetty9
  30. 30. Components jgroups jsonpath leveldb mustache jibx jt400 linkedin mvel jing juel lucene mybatis jira jxpath mail netty jms kafka metrics netty-http jmx kestrel mina netty4 jolt krati mina2 netty4-http josql kubernetes mongodb ognl jpa kura mqtt olingo2 jsch ldap msv openshift
  31. 31. Components optaplanner rabbitmq scala smpp paho restlet schematron snpp paxlogging rmi scr soap pdf routebox script solr pgevent rss servlet spark-rest printer ruby servletlistener spring protobuf rx shiro spring-batch quartz salesforce sip spring-boot quarz2 sap-netweaver sjms spring-integration quickfix saxon slack spring-javaconfig
  32. 32. Components spring-ldap swagger undertow xmlsecurity spring-redis swagger-java univocity xmpp spring-security syslog urlrewrite xstream spring-ws tagsoup velocity yammer sql tarfile vertx zipfile ssh test weather zookeeper stax test-blueprint websocket stomp test-spring xmlbeans stream testng xmljson stringtemplate twitter xmlrpc
  33. 33. +
  34. 34. + +
  35. 35. + + +
  36. 36. + + + =
  37. 37. Apache Camel on GitHub Numbers • Project created March 2007 • 1058 Stars • 102 Releases • 25000+ Commits • 253 Contributors • 1254 Closed Pull Requests A star on github is appreciated
  38. 38. Agenda • What is Apache Camel? • Little Example • Trying Apache Camel • What's in the Camel Box? • Running Camel • More Information
  39. 39. File Copier Example
  40. 40. Public Static Void Main
  41. 41. Create CamelContext
  42. 42. Add RouteBuilder
  43. 43. Java DSL
  44. 44. Start / Stop
  45. 45. Camel Main
  46. 46. Agenda • What is Apache Camel? • Little Example • Trying Apache Camel • What's in the Camel Box? • Running Camel • More Information
  47. 47. Trying Camel • Download Apache Camel 2.18.0 • tar xf apache-camel-2.18.0.tar.gz • cd apache-camel-2.18.0 • cd examples read readme.md first
  48. 48. Beginner Example • camel-example-console mvn camel:run
  49. 49. Run with web console mvn io.hawt:hawtio-maven-plugin:1.4.66:camel http://hawt.io/maven
  50. 50. Spring Boot Starter
  51. 51. Spring Boot
  52. 52. WildFly Swarm Generator
  53. 53. WildFly Swarm CDI
  54. 54. Apache ServiceMix • Download Apache ServiceMix 7.0.0.M2 • unzip apache-servicemix-7.0.0.M2.zip • cd apache-servicemix-7.0.0.M2 • cd examples/camel read readme.txt first
  55. 55. Agenda • What is Apache Camel? • Little Example • Trying Apache Camel • What's in the Camel Box? • More Information
  56. 56. What's in the Camel Box?
  57. 57. Enterprise Integration Patterns http://camel.apache.org/eip
  58. 58. Splitter
  59. 59. Splitter from("file:inbox")
  60. 60. Splitter from("file:inbox") .split(body().tokenize("n"))
  61. 61. Splitter from("file:inbox") .split(body().tokenize("n")) .marshal(customToXml) Custom Data Format
  62. 62. Splitter from("file:inbox") .split(body().tokenize("n")) .marshal(customToXml) .to("activemq:line"); Custom Data Format
  63. 63. Components ahc bindy coap docker ahc-ws blueprint cometd dozer apns boon context dropbox atmosphere box couchdb eclipse atom cache crypto ejb aws cassandraql csv elasticsearch bam castor cfx elsql bean-validator cdi cxf-transport eventadmin beanio chunk disruptor exec beanstalk cmis dns facebook camel-catalog:component-list | wc -l 219
  64. 64. Data Formats avro flatpack pgp univocity-fixed barcode gzip protobuf univocity-tsv base64 hl7 rss xmlBeans beanio ical secureXML xmjson bindy-csv jacksonxml serialization xmlrpc bindy-fixed jaxb soapjaxb xstream bindy-kvp jibx string zip boon json-gson syslog zipfile castor json-jackson tarfile crypto json-xstream tidyMarkup csv mime-multipart univocity-csv camel-catalog:dataformat-list | wc -l 47
  65. 65. Data Format with JAXB • POJO class with @JAXB annotations
  66. 66. Data Format with JAXB • marshal (xml -> pojo) • unmarshal (pojo -> xml)
  67. 67. Languages bean header php sql constant javaScript python terser el jsonpath ref tokenize exchange Proper ty jxpath ruby xpath file mvel simple xquery groovy ognl spel xtokenize camel-catalog:language-list | wc -l 26
  68. 68. Language w/ Simple
  69. 69. Language w/ Groovy here you can do groovy programming
  70. 70. Camel DSLs • Java DSL • XML DSL (spring or OSGi blueprint) • Groovy DSL • Scala DSL Groovy and Scala are not much in use Java8 DSL in the works
  71. 71. ProducerTemplate • Client API (alike Spring Templates) Send a message to any Camel endpoint
  72. 72. ProducerTemplate • Client API (alike Spring Templates) FTP server Java Application How to upload a file to a FTP server from Java code
  73. 73. ProducerTemplate FTP server Java Application
  74. 74. FluentProducerTemplat e FTP server Java Application
  75. 75. Test Kit camel-test camel-test-blueprint camel-test-cdi camel-test-karaf camel-test-spring camel-testng
  76. 76. camel-test
  77. 77. camel-test easy to run or debug
  78. 78. camel-test 1) set expectations
  79. 79. camel-test 1) set expectations 2) send message(s)
  80. 80. camel-test 1) set expectations 2) send message(s) 3) assert
  81. 81. Management • JMX
  82. 82. • Reliable Shutdown Graceful Shutdown Route A Route B Route C 2 1 3 4 5 6 Startup Shutdown Stop accept new messages Complete current inflight messages
  83. 83. Camel Commands • Apache Karaf / ServiceMix
  84. 84. Camel Commands • Spring Boot
  85. 85. Rest DSL (XML)
  86. 86. Rest DSL (Java) use REST verbs to define services that becomes Camel routes
  87. 87. Rest DSL configure REST and turn on swagger api
  88. 88. Swagger Doc swagger doc as json schema
  89. 89. Swagger Doc embedded swagger-ui
  90. 90. Rest DSL Example cd examples/camel-example-swagger-xml mvn jetty:run
  91. 91. Error Handling
  92. 92. Error Handling
  93. 93. Error Handling
  94. 94. Error Handling
  95. 95. Circuit Breaker • Netflixx Hystrix New in Camel 2.18
  96. 96. Circuit Breaker • Integrates with Hystrix Dashboard
  97. 97. Maven Tooling • Archetypes camel-archetype-java camel-archetype-component camel-archetype-spring camel-archetype-api-component camel-archetype-web camel-archetype-dataformat camel-archetype-cdi camel-archetype-spring-boot camel-archetype-scala camel-archetype-blueprint camel-archetype-groovy camel-archetype-spring-dm camel-archetype-scr camel-archetype-java8 New in Camel 2.18
  98. 98. Maven Tooling • camel-maven-plugin mvn camel:run
  99. 99. Maven Tooling • fabric8-camel-maven-plugin mvn fabric8-camel:validate http://fabric8.io/guide/camelMavenPlugin.html Validate your Camel uris from the source
  100. 100. All the other stuff Type Converter Transactions Interceptors Security Thread Management Route Policy Java8 DSL Asynchronous Non-Blocking Routing Engine POJO Routing Debugging & Tracing
  101. 101. Agenda • What is Apache Camel? • Little Example • Trying Apache Camel • What's in the Camel Box? • Running Camel • More Information
  102. 102. Running Camel Standalone Web Application Camel Spring XML JEE Application Camel Spring Boot Apache Karaf / ServiceMix (OSGi) Camel CDI WildFly / WildFly-Swarm (wildfly- camel) Camel Guice vert.x (vertx-camel)
  103. 103. More Information • My blog • http://www.davsclaus.com • Apache Camel 3rd party blogs/articles/etc • http://camel.apache.org/articles • Camel videos • https://vimeo.com/tag:apachecamel • Best What is Camel article • https://dzone.com/articles/open-source- integration-apache Also videos on Youtube @davsclaus davsclaus davsclaus.com claus.ibsen@gmail.com

×