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.

Apache Camel Introduction & What's in the box

3,902 views

Published on

Slides from JavaBin talk in Grimstad Norway, presented by Claus Ibsen in February 2016.

This slide deck is full up to date with latest Apache Camel 2.16.2 release and includes additional slides to present many of the features that Apache Camel provides out of the box.

Published in: Internet
  • DOWNLOAD FULL. BOOKS INTO AVAILABLE FORMAT ......................................................................................................................... ......................................................................................................................... 1.DOWNLOAD FULL. PDF EBOOK here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL. EPUB Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL. doc Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL. PDF EBOOK here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL. EPUB Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL. doc Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Hey guys! Who wants to chat with me? More photos with me here 👉 http://www.bit.ly/katekoxx
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Apache Camel Introduction & What's in the box

  1. 1. Apache Camel
 Introduction & What's in the box Claus Ibsen @davsclaus
  2. 2. Claus Ibsen • Principal Software Engineer at Red Hat • Apache Camel • 8 years working with Camel • Author of Camel in Action books @davsclaus davsclaus.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. Camel Java Tooling Camel Forge
  27. 27. Just XML
  28. 28. Camel XML Tooling
  29. 29. Camel XML Tooling http://tools.jboss.org/features/apachecamel.html
  30. 30. Architecture
  31. 31. 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
  32. 32. 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
  33. 33. 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
  34. 34. 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
  35. 35. 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
  36. 36. +
  37. 37. + +
  38. 38. + + +
  39. 39. + + + =
  40. 40. Agenda • What is Apache Camel? • Little Example • Trying Apache Camel • What's in the Camel Box? • Running Camel • More Information
  41. 41. File Copier Example
  42. 42. Public Static Void Main
  43. 43. Create CamelContext
  44. 44. Add RouteBuilder
  45. 45. Java DSL
  46. 46. Start / Stop
  47. 47. Camel Main
  48. 48. Agenda • What is Apache Camel? • Little Example • Trying Apache Camel • What's in the Camel Box? • Running Camel • More Information
  49. 49. Trying Camel • Download Apache Camel 2.16.2 • tar xf apache-camel-2.16.2.tar.gz • cd apache-camel-2.16.2 • cd examples read readme.md first
  50. 50. Beginner Example • camel-example-console mvn camel:run
  51. 51. Run with web console mvn io.hawt:hawtio-maven-plugin:1.4.60:camel http://hawt.io/maven
  52. 52. Widget & Gadget Example • camel-example-widget-gadget-xml bin/activemq console mvn exec:java There is a Java example also Requires ActiveMQ running
  53. 53. Agenda • What is Apache Camel? • Little Example • Trying Apache Camel • What's in the Camel Box? • More Information
  54. 54. What's in the Camel Box?
  55. 55. Enterprise Integration Patterns http://camel.apache.org/eip
  56. 56. Pipes and Filters EIP from("file:inbox") .pipeline() .to("bean:decrypt") .to("bean:authenticate") .to("bean:de-dup");
  57. 57. Pipes and Filters EIP from("file:inbox") .to("bean:decrypt") .to("bean:authenticate") .to("bean:de-dup"); pipeline is default mode so its
 nearly always omitted
  58. 58. Recipient List from("reslet:http://localhost:9080
 /stocks/{symbol}?restletMethods=post") .recipientList(simple("activemq:queue:${header.symbol}")); curl -X POST -d "120" "http://localhost:9080/stock/ORCL"
  59. 59. Recipient List from("reslet:http://localhost:9080
 /stocks/{symbol}?restletMethods=post") .recipientList(simple("activemq:queue:${header.symbol}")); curl -X POST -d "120" "http://localhost:9080/stock/ORCL"
  60. 60. Recipient List from("reslet:http://localhost:9080
 /stocks/{symbol}?restletMethods=post") .toD("activemq:queue:${header.symbol}")); much easier now with toD
 (to dynamic) curl -X POST -d "120" "http://localhost:9080/stock/ORCL"
  61. 61. Recipient List restConfiguration().component("restlet").port(9080);
 rest("stocks") .post("{symbol}") .toD("activemq:queue:${header.symbol}")); and use rest-dsl curl -X POST -d "120" "http://localhost:9080/stock/ORCL"
  62. 62. Splitter
  63. 63. Splitter from("file:inbox")
  64. 64. Splitter from("file:inbox") .split(body().tokenize("n"))
  65. 65. Splitter from("file:inbox") .split(body().tokenize("n")) .marshal(customToXml) Custom Data Format
  66. 66. Splitter from("file:inbox") .split(body().tokenize("n")) .marshal(customToXml) .to("activemq:line"); Custom Data Format
  67. 67. 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 207
  68. 68. 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 41
  69. 69. Data Format with JAXB • POJO class with @JAXB annotations
  70. 70. Data Format with JAXB • marshal (xml -> pojo) • unmarshal (pojo -> xml)
  71. 71. Languages bean header php sql constant javaScript python terser el jsonpath ref tokenize exchange
 Property jxpath ruby xpath file mvel simple xquery groovy ognl spel xtokenize camel-catalog:language-list | wc -l 24
  72. 72. Language w/ Simple
  73. 73. Language w/ Groovy here you can do groovy programming
  74. 74. Camel DSLs • Java DSL • XML DSL (spring or OSGi blueprint) • Groovy DSL • Scala DSL Groovy and Scala
 are not much in use
  75. 75. Type Converters DefaultTypeConverter INFO
 Loaded 183 type converters
  76. 76. Type Converters • Camel provides
 type converters
 for most common
 types in Java hawtio can list the converters
  77. 77. Type Converters explicit type conversion
 using convertBodyTo
  78. 78. Type Converters implicit type conversion Camel will automatic convert from java.io.File to String
  79. 79. Writing custom
 Type Converter META-INF/services/org/apache/camel/TypeConverter com.acme.MyTypeConverter
  80. 80. Property Placeholders • Externalize configuration myapp.properties hi=Hello port=9090 myQueueName=greeting
  81. 81. • Camel PropertyPlaceholder Property Placeholders
  82. 82. Property Placeholders • Bridge with Spring Property Placeholder Spring: ${xxx} Camel: {{xxx}}
  83. 83. ProducerTemplate • Client API (alike Spring Templates) Send a message to any Camel endpoint
  84. 84. ProducerTemplate • Client API (alike Spring Templates) FTP server Java Application How to upload a file to a FTP server from Java code
  85. 85. ProducerTemplate FTP server Java Application
  86. 86. Test Kit camel-test camel-test-blueprint camel-test-spring camel-testng camel-test-cdi in the works
  87. 87. camel-test
  88. 88. camel-test easy to run or debug
  89. 89. camel-test 1) set expectations
  90. 90. camel-test 1) set expectations 2) send message(s)
  91. 91. camel-test 1) set expectations 2) send message(s) 3) assert
  92. 92. camel-test-spring Notice the extends
  93. 93. Testing 'Production' Routes how to test route without any mock endpoints ?
  94. 94. MockAndSkip mock and skip sending to the target endpoint TIP you can also use wildcards and not skip mock: added as prefix
  95. 95. AdviceWith enable adviceWith add mock endpoint last start Camel after adviceWith
  96. 96. NotifyBuilder Blackbox testing the 'production' route
  97. 97. NotifyBuilder
  98. 98. NotifyBuilder 1) set expectations 2) send message(s) 3) assert
  99. 99. Management • JMX
  100. 100. Management • REST (w/ Jolokia) jolokia/exec/ org.apache.camel:context=camel,type=context,
 name="camel"/dumpRoutesAsXml()
  101. 101. hawtio uses Jolokia http://hawt.io/
  102. 102. Management • Java API
  103. 103. • Control Bus Management to stop a route from a route
  104. 104. Inflight Repository • Track messages during routing
  105. 105. • 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
  106. 106. Camel Commands • Apache Karaf / JBoss Fuse
 
 
 
 

  107. 107. Camel Commands • Spring Boot
  108. 108. Camel Commands • fabric8-forge
  109. 109. Rest DSL use REST verbs to define services that becomes Camel routes
  110. 110. Rest DSL configure REST and turn on swagger api
  111. 111. Rest DSL cd examples/camel-example-swagger-java mvn jetty:run
  112. 112. Rest DSL swagger doc as json schema
  113. 113. Rest DSL embedded swagger-ui
  114. 114. Error Handling
  115. 115. Error Handling
  116. 116. Error Handling
  117. 117. Error Handling
  118. 118. 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
  119. 119. Maven Tooling • camel-maven-plugin mvn camel:run
  120. 120. Maven Tooling • fabric8-camel-maven-plugin mvn fabric8-camel:validate http://fabric8.io/guide/camelMavenPlugin.html Validate your Camel uris from the source
  121. 121. All the other stuff • Transactions • Interceptors • Security • Thread Management • Route Policy • Reactive Asynchronous Routing Engine • POJO Routing • Debugging and Tracing
  122. 122. Agenda • What is Apache Camel? • Little Example • Trying Apache Camel • What's in the Camel Box? • Running Camel • More Information
  123. 123. Running Camel Standalone Web Application Camel Spring XML JEE Application Camel Spring Boot Apache Karaf (OSGi) Camel CDI Wildfly
 (wildfly-camel) Camel Guice vert.x
 (vertx-camel)
  124. 124. Running Camel Just need a Java Runtime
  125. 125. Running Camel
  126. 126. 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 • Free chapter 1 covers Camel concepts to learn • http://manning.com/ibsen/chapter1sample.pdf @davsclaus davsclaus.com

×