Getting started with Apache Camel - Javagruppen Copenhagen - April 2014

Embed Size (px)

DESCRIPTION

This session will teach you how to get a good start with Apache Camel. We will introduce you to Apache Camel and how Camel its related to Enterprise Integration Patterns. And how you go about using these patterns in Camel routes, written in Java code or XML files. We will then discuss how you can get started developing with Camel, and how to setup a new project from scratch using Maven and Eclipse tooling. This session includes live demos that show how to build Camel applications in Java, Spring, OSGi Blueprint and alternative languages such as Scala and Groovy. You will also hear what other features Camel provides out of the box, which can make integration much easier for you. At the end we demonstrate how to build custom components, allowing you to build custom adapters if not already provided by Camel. Before opening up for QA, we will share useful links where you can dive into learning more about Camel.

Citation preview

  • 1. Getting Started with Apache CamelClaus Ibsen (@davsclaus)Principal Software Engineer, Red HatJavagruppen Copenhagen, april 20131 PUBLIC PRESENTATION | CLAUS IBSEN

2. Agenda History of Camel What is Apache Camel? A little Example Riding Camel Whats in the Camel box? Deploying Camel Creating new Camel Projects Q and A2PUBLIC PRESENTATION | CLAUS IBSEN 3. Your Speaker Principal Software Engineer at Red Hat Apache Camel 5 years working with Camel Author of Camel in Action book Contact EMail: [email protected] Twitter: @davsclaus Blog: http://davsclaus.com Linkedin: http://www.linkedin.com/in/davsclaus3 PUBLIC PRESENTATION | CLAUS IBSEN 4. Why the name Camel?4 PUBLIC PRESENTATION | CLAUS IBSEN 5. Why the name Camel?Because Camel iseasy to remember and type ...5PUBLIC PRESENTATION | CLAUS IBSEN 6. Why the name Camel? or the creator used to smoke cigarets! http://camel.apache.org/why-the-name-camel.html6PUBLIC PRESENTATION | CLAUS IBSEN 7. Camels parents7 PUBLIC PRESENTATION | CLAUS IBSEN 8. Camels parents James Strachan (creator of Camel) Gregor Hohpe (author of EIP book)8 PUBLIC PRESENTATION | CLAUS IBSEN 9. The birth of Camel First Commit9PUBLIC PRESENTATION | CLAUS IBSEN 10. The birth of Camel My first Commit10 PUBLIC PRESENTATION | CLAUS IBSEN 11. The birth of Camel First Release Apache Camel 1.0June 2007http://www.davsclaus.com/2012/05/looking-at-impressive-first-apache.html11 PUBLIC PRESENTATION | CLAUS IBSEN 12. Agenda History of Camel What is Apache Camel? A little Example Riding Camel Whats in the Camel box? Deploying Camel Creating new Camel Projects Q and A12PUBLIC PRESENTATION | CLAUS IBSEN 13. What is Apache Camel? Quote from the website13 PUBLIC PRESENTATION | CLAUS IBSEN 14. What is Apache Camel? Why do we need integration? Critical for your business to integrate Why Integration Framework? Framework do the heavy lifting You can focus on business problem Not "reinventing the wheel"14 PUBLIC PRESENTATION | CLAUS IBSEN 15. What is Apache Camel? What is Enterprise Integration Patterns? Its a book15 PUBLIC PRESENTATION | CLAUS IBSEN 16. What is Apache Camel? Enterprise Integration Patternshttp://camel.apache.org/eip16 PUBLIC PRESENTATION | CLAUS IBSEN 17. What is Apache Camel? EIP - Content Based Router17 PUBLIC PRESENTATION | CLAUS IBSEN 18. What is Apache Camel? from newOrder18 PUBLIC PRESENTATION | CLAUS IBSEN 19. What is Apache Camel? from newOrder choice19 PUBLIC PRESENTATION | CLAUS IBSEN 20. What is Apache Camel? from newOrder choice when isWidget to widget20 PUBLIC PRESENTATION | CLAUS IBSEN 21. What is Apache Camel? from newOrder choice when isWidget to widget otherwise to gadget21 PUBLIC PRESENTATION | CLAUS IBSEN 22. What is Apache Camel? from(newOrder) choice when(isWidget) to(widget) otherwise to(gadget)22 PUBLIC PRESENTATION | CLAUS IBSEN 23. What is Apache Camel? from(newOrder) .choice() .when(isWidget).to(widget) .otherwise().to(gadget);23 PUBLIC PRESENTATION | CLAUS IBSEN 24. What is Apache Camel? Endpoint newOrder = endpoint("activemq:queue:newOrder"); from(newOrder) .choice() .when(isWidget).to(widget) .otherwise().to(gadget);24 PUBLIC PRESENTATION | CLAUS IBSEN 25. What is Apache Camel? Endpoint newOrder = endpoint("activemq:queue:newOrder"); Predicate isWidget = xpath("/order/product = widget"); from(newOrder) .choice() .when(isWidget).to(widget) .otherwise().to(gadget);25 PUBLIC PRESENTATION | CLAUS IBSEN 26. What is Apache Camel? 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);26 PUBLIC PRESENTATION | CLAUS IBSEN 27. What is Apache Camel? Java Codepublic 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).end();}27 PUBLIC PRESENTATION | CLAUS IBSEN 28. What is Apache Camel? 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) .end(); } }28PUBLIC PRESENTATION | CLAUS IBSEN 29. What is Apache Camel? Camel 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") .end(); } }29PUBLIC PRESENTATION | CLAUS IBSEN 30. What is Apache Camel? Camel XML DSL/order/product = widget30 PUBLIC PRESENTATION | CLAUS IBSEN 31. What is Apache Camel?use file instead Endpoint as URIs/order/product = widget31 PUBLIC PRESENTATION | CLAUS IBSEN 32. What is Apache Camel? parameters Endpoint as URIs/order/product = widget32 PUBLIC PRESENTATION | CLAUS IBSEN 33. What is Apache Camel? Camels Architecture33 PUBLIC PRESENTATION | CLAUS IBSEN 34. What is Apache Camel? 120+ Components34 PUBLIC PRESENTATION | CLAUS IBSEN 35. What is Apache Camel? 120+ Components35 PUBLIC PRESENTATION | CLAUS IBSEN 36. What is Apache Camel? Summary Integration Framework Enterprise Integration Patterns (EIP) Routing (using DSL) Easy Configuration (endpoint as uris) Payload Agnostic No Container Dependency A lot of components36PUBLIC PRESENTATION | CLAUS IBSEN 37. Agenda History of Camel What is Apache Camel? A little Example Riding Camel Whats in the Camel box? Deploying Camel Creating new Camel Projects Extending Camel Q and A37PUBLIC PRESENTATION | CLAUS IBSEN 38. A Little Example File Copier Example38 PUBLIC PRESENTATION | CLAUS IBSEN 39. A Little Example File Copier Example39 PUBLIC PRESENTATION | CLAUS IBSEN 40. A Little Example File Copier Example40 PUBLIC PRESENTATION | CLAUS IBSEN 41. A Little Example File Copier Example41 PUBLIC PRESENTATION | CLAUS IBSEN 42. A Little Example File Copier Example42 PUBLIC PRESENTATION | CLAUS IBSEN 43. Agenda History of Camel What is Apache Camel? A little Example Riding Camel Whats in the Camel box? Deploying Camel Creating new Camel Projects Q and A43PUBLIC PRESENTATION | CLAUS IBSEN 44. Riding Camel Downloading Apache Camel zip/tarball (approx 14mb)http://camel.apache.org44PUBLIC PRESENTATION | CLAUS IBSEN 45. Riding Camel Using Command Shell Requires: Apache Maven From Eclipse45 PUBLIC PRESENTATION | CLAUS IBSEN 46. Riding Camel Console Example cd examples/camel-example-console mvn compile exec:java46 PUBLIC PRESENTATION | CLAUS IBSEN 47. Riding Camel Twitter Example cd examples/camel-example-twitter-websocket mvn compile exec:javahttp://localhost:9090/index.html47 PUBLIC PRESENTATION | CLAUS IBSEN 48. Riding Camel More examples ... ... and further details at website.http://camel.apache.org/examples48PUBLIC PRESENTATION | CLAUS IBSEN 49. Agenda History of Camel What is Apache Camel? A little Example Riding Camel Whats in the box? Deploying Camel Creating new Camel Projects Q and A49PUBLIC PRESENTATION | CLAUS IBSEN 50. Whats in the box?50 PUBLIC PRESENTATION | CLAUS IBSEN 51. Whats in the box? Enterprise Integration Patternshttp://camel.apache.org/eip51 PUBLIC PRESENTATION | CLAUS IBSEN 52. Whats in the box? Splitter EIP52 PUBLIC PRESENTATION | CLAUS IBSEN 53. What is Apache Camel? 120+ Components53 PUBLIC PRESENTATION | CLAUS IBSEN 54. What is Apache Camel? 19 Data Formats54 PUBLIC PRESENTATION | CLAUS IBSEN 55. What is Apache Camel? 15 Expression Languages55PUBLIC PRESENTATION | CLAUS IBSEN 56. What is Apache Camel? 5+ DSL in multiple languages Java DSL XML DSL (Spring and OSGi Blueprint) Groovy DSL Scala DSL Kotlin DSL (work in progress)56 PUBLIC PRESENTATION | CLAUS IBSEN 57. What is Apache Camel? Test Kit camel-testcamel-test-spring camel-test-blueprintcamel-testng57PUBLIC PRESENTATION | CLAUS IBSEN 58. What is Apache Camel? Management JMX REST (@deprecated)58 PUBLIC PRESENTATION | CLAUS IBSEN 59. What is Apache Camel? Tooling Web console - HawtIO http://hawt.io59 PUBLIC PRESENTATION | CLAUS IBSEN 60. What is Apache Camel? Tooling Eclipse Plugin Fuse IDEhttp://github.com/fusesource/fuseide60PUBLIC PRESENTATION | CLAUS IBSEN 61. What is Apache Camel? Error Handling61PUBLIC PRESENTATION | CLAUS IBSEN 62. What is Apache Camel? try .. catch style62PUBLIC PRESENTATION | CLAUS IBSEN 63. What is Apache Camel? Dead Letter Channel (EIP style)63PUBLIC PRESENTATION | CLAUS IBSEN 64. What is Apache Camel? The Rest Interceptors Security Route Policy Type Converters Transaction Compensation as rollback Asynchronous non-blocking routing engine Thread management Maven Tooling ... and much more64 PUBLIC PRESENTATION | CLAUS IBSEN 65. Agenda History of Camel What is Apache Camel? A little Example Riding Camel Whats in the Camel box? Deploying Camel Creating new Camel Projects Extending Camel Q and A65PUBLIC PRESENTATION | CLAUS IBSEN 66. Deploying Camel Deployment Strategy No Container Dependency Lightweight & Embeddable Deployment Options Standalone WAR Spring JEE OSGi Cloud66 PUBLIC PRESENTATION | CLAUS IBSEN 67. Camel as a Client Java Client Application (no routes) Example Upload a file to a FTP server67PUBLIC PRESENTATION | CLAUS IBSEN 68. Agenda History of Camel What is Apache Camel? A little Example Riding Camel Whats in the Camel box? Deploying Camel Creating new Camel Projects Q and A68PUBLIC PRESENTATION | CLAUS IBSEN 69. Creating new Camel Projects Using Command Shell From Eclipse69 PUBLIC PRESENTATION | CLAUS IBSEN 70. Creating new Camel Projects Maven Archetypes70PUBLIC PRESENTATION | CLAUS IBSEN 71. Creating new Camel Projects camel-archetype-blueprint71 PUBLIC PRESENTATION | CLAUS IBSEN 72. Creating new Camel Projects Importing into Eclipse Existing Maven Project72PUBLIC PRESENTATION | CLAUS IBSEN 73. Creating new Camel Projects Testing Camel Projects ... from inside Eclipse73 PUBLIC PRESENTATION | CLAUS IBSEN 74. Agenda History of Camel What is Apache Camel? A little Example Riding Camel Whats in the Camel box? Deploying Camel Creating new Camel Projects Q and A74PUBLIC PRESENTATION | CLAUS IBSEN 75. Where do I get more information? Best Article covering what Apache Camel is http://java.dzone.com/articles/open-source-integration-apacheLink to article from Getting Started75PUBLIC PRESENTATION | CLAUS IBSEN 76. Where do I get more information? Try Camel Examples http://camel.apache.org/examples.html Read other blogs and articles http://camel.apache.org/articles.html Use the search box on the Camel front page76PUBLIC PRESENTATION | CLAUS IBSEN 77. Where do I get more information? Use the mailing list / forum http://camel.apache.org/mailing-lists.html Use stackoverflow http://stackoverflow.com/questions/tagged/apache-camel77PUBLIC PRESENTATION | CLAUS IBSEN 78. Where do I get more information? Buy the Camel in Action bookUse code ...camel40 for 40% discount http://manning.com/ibsen/78 PUBLIC PRESENTATION | CLAUS IBSEN 79. Any Questions ?Contact EMail: [email protected] Twitter: @davsclaus Blog: http://davsclaus.com Linkedin: http://www.linkedin.com/in/davsclaus79PUBLIC PRESENTATION | CLAUS IBSEN