Your SlideShare is downloading. ×
Integration using Apache Camel and Groovy
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Saving this for later?

Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime - even offline.

Text the download link to your phone

Standard text messaging rates apply

Integration using Apache Camel and Groovy

1,284
views

Published on

Apache Camel is versatile integration library that supports a huge number of components, enterprise integration patterns, and programming languages. …

Apache Camel is versatile integration library that supports a huge number of components, enterprise integration patterns, and programming languages.

In this this talk I first introduce you to Apache Camel and its concepts. Then we move on to see how you can use the Groovy programming language with Camel as a first class Groovy DSL to build integration flows.

You will also learn how to build a new Camel and Groovy app from scratch from a live demo.

And we also touch how you can use Camel from grails using the grails-camel plugin.

I will also show the web console tools that give you insight into your running Apache Camel applications, including visual route diagrams with tracing, debugging, and profiling capabilities.

This session will be taught with a 50/50 mix of slides and live demos, and it will conclude with Q&A time.

Published in: Software, Technology, Education

0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,284
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
33
Comments
0
Likes
3
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Claus Ibsen Red Hat ● Integration using Apache Camel & Groovy
  • 2. PUBLIC PRESENTATION | CLAUS IBSEN2 Your Speaker ● Principal Software Engineer at Red Hat ● Apache Camel ● 6 years as committer ● Author of Camel in Action book ● Contact ● EMail: claus.ibsen@gmail.com ● Twitter: @davsclaus ● Blog: http://davsclaus.com ● Linkedin: http://www.linkedin.com/in/davsclaus
  • 3. PUBLIC PRESENTATION | CLAUS IBSEN3 This awesome ...
  • 4. PUBLIC PRESENTATION | CLAUS IBSEN4 These two awesome has ...
  • 5. PUBLIC PRESENTATION | CLAUS IBSEN5 These three awesome has ...
  • 6. PUBLIC PRESENTATION | CLAUS IBSEN6 These three awesome has something in common
  • 7. PUBLIC PRESENTATION | CLAUS IBSEN7 Agenda ● What is Apache Camel? ● A little Example ● Riding Camel ● Creating new Camel Projects ● hawtio ● Q & A
  • 8. PUBLIC PRESENTATION | CLAUS IBSEN8 Why the name Camel?
  • 9. PUBLIC PRESENTATION | CLAUS IBSEN9 Why the name Camel? Because Camel is easy to remember and type ...
  • 10. PUBLIC PRESENTATION | CLAUS IBSEN10 Why the name Camel? … or the creator used to smoke cigarets! http://camel.apache.org/why-the-name-camel.html
  • 11. PUBLIC PRESENTATION | CLAUS IBSEN11 What is Apache Camel? ● Quote from the website
  • 12. PUBLIC PRESENTATION | CLAUS IBSEN12 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"
  • 13. PUBLIC PRESENTATION | CLAUS IBSEN13 What is Apache Camel? ● What is Enterprise Integration Patterns? It's a book
  • 14. PUBLIC PRESENTATION | CLAUS IBSEN14 What is Apache Camel? ● Enterprise Integration Patterns http://camel.apache.org/eip
  • 15. PUBLIC PRESENTATION | CLAUS IBSEN15 What is Apache Camel? ● EIP - Content Based Router
  • 16. PUBLIC PRESENTATION | CLAUS IBSEN16 What is Apache Camel? from newOrder
  • 17. PUBLIC PRESENTATION | CLAUS IBSEN17 What is Apache Camel? from newOrder choice
  • 18. PUBLIC PRESENTATION | CLAUS IBSEN18 What is Apache Camel? from newOrder choice when isWidget to widget
  • 19. PUBLIC PRESENTATION | CLAUS IBSEN19 What is Apache Camel? from newOrder choice when isWidget to widget otherwise to gadget
  • 20. PUBLIC PRESENTATION | CLAUS IBSEN20 What is Apache Camel? from(newOrder) choice when(isWidget) to(widget) otherwise to(gadget)
  • 21. PUBLIC PRESENTATION | CLAUS IBSEN21 What is Apache Camel? from(newOrder) .choice() .when(isWidget).to(widget) .otherwise().to(gadget);
  • 22. PUBLIC PRESENTATION | CLAUS IBSEN22 What is Apache Camel? from(newOrder) .choice() .when(isWidget).to(widget) .otherwise().to(gadget); Ups Sorry ... This is a gr8conf so lets get Groovy :)
  • 23. PUBLIC PRESENTATION | CLAUS IBSEN23 What is Apache Camel? from newOrder choice when isWidget to widget otherwise to gadget
  • 24. PUBLIC PRESENTATION | CLAUS IBSEN24 What is Apache Camel? from newOrder choice when isWidget to widget otherwise to gadget Unfortunately the Camel Groovy DSL is not as awesome … yet
  • 25. PUBLIC PRESENTATION | CLAUS IBSEN25 What is Apache Camel? from(newOrder) .choice() .when(isWidget).to(widget) .otherwise().to(gadget) We removed that last semi colon ;)
  • 26. PUBLIC PRESENTATION | CLAUS IBSEN26 What is Apache Camel? Endpoint newOrder = endpoint("activemq:queue:newOrder"); from(newOrder) .choice() .when(isWidget).to(widget) .otherwise().to(gadget);
  • 27. PUBLIC PRESENTATION | CLAUS IBSEN27 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);
  • 28. PUBLIC PRESENTATION | CLAUS IBSEN28 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);
  • 29. PUBLIC PRESENTATION | CLAUS IBSEN29 What is Apache Camel? ● 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) .end(); }
  • 30. PUBLIC PRESENTATION | CLAUS IBSEN30 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(); } }
  • 31. PUBLIC PRESENTATION | CLAUS IBSEN31 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(); } }
  • 32. PUBLIC PRESENTATION | CLAUS IBSEN32 What is Apache Camel? ● Camel 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>
  • 33. PUBLIC PRESENTATION | CLAUS IBSEN33 What is Apache Camel? ● Endpoint as 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
  • 34. PUBLIC PRESENTATION | CLAUS IBSEN34 What is Apache Camel? ● Endpoint as 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
  • 35. PUBLIC PRESENTATION | CLAUS IBSEN35 Standard Java, XML, or Groovy ● Java DSL is just Java
  • 36. PUBLIC PRESENTATION | CLAUS IBSEN36 Standard Java, XML, or Groovy ● XML DSL is just XML ● … with XSD schema for validation/tooling
  • 37. PUBLIC PRESENTATION | CLAUS IBSEN37 Standard Java, XML, or Groovy ● Groovy DSL is just Groovy Groovy Closure
  • 38. PUBLIC PRESENTATION | CLAUS IBSEN38 What is Apache Camel? ● Camel's Architecture
  • 39. PUBLIC PRESENTATION | CLAUS IBSEN39 What is Apache Camel? 150+ Components
  • 40. PUBLIC PRESENTATION | CLAUS IBSEN40 What is Apache Camel? 150+ Components
  • 41. PUBLIC PRESENTATION | CLAUS IBSEN41 What is Apache Camel? ● Summary ● Integration Framework ● Enterprise Integration Patterns (EIP) ● Routing (using DSL) ● Easy Configuration (endpoint as uri's) ● Just Java, XML, or Groovy code ● No Container Dependency ● A lot of components
  • 42. PUBLIC PRESENTATION | CLAUS IBSEN42 Agenda ● What is Apache Camel? ● A little Example ● Riding Camel ● Creating new Camel Projects ● hawtio ● Q & A
  • 43. PUBLIC PRESENTATION | CLAUS IBSEN43 A Little Example ● File Copier Example
  • 44. PUBLIC PRESENTATION | CLAUS IBSEN44 A Little Example ● File Copier Example
  • 45. PUBLIC PRESENTATION | CLAUS IBSEN45 A Little Example ● File Copier Example
  • 46. PUBLIC PRESENTATION | CLAUS IBSEN46 A Little Example ● File Copier Example
  • 47. PUBLIC PRESENTATION | CLAUS IBSEN47 A Little Example ● File Copier Example
  • 48. PUBLIC PRESENTATION | CLAUS IBSEN48 A Little Groovy Example
  • 49. PUBLIC PRESENTATION | CLAUS IBSEN49 A Little Groovy Example (all source)
  • 50. PUBLIC PRESENTATION | CLAUS IBSEN50 A Little Groovy Example ● Run the example ● groovy mycamel.groovy
  • 51. PUBLIC PRESENTATION | CLAUS IBSEN51 Agenda ● What is Apache Camel? ● A little Example ● Riding Camel ● Creating new Camel Projects ● hawtio ● Q & A
  • 52. PUBLIC PRESENTATION | CLAUS IBSEN52 Riding Camel ● Downloading Apache Camel ● zip/tarball (approx 8mb) http://camel.apache.org
  • 53. PUBLIC PRESENTATION | CLAUS IBSEN53 Riding Camel ● Using Command Shell ● Requires: Apache Maven ● From Eclipse
  • 54. PUBLIC PRESENTATION | CLAUS IBSEN54 Riding Camel ● Console Example ● cd examples/camel-example-console ● mvn compile exec:java
  • 55. PUBLIC PRESENTATION | CLAUS IBSEN55 Riding Camel ● Twitter Example ● cd examples/camel-example-twitter-websocket ● mvn compile exec:java http://localhost:9090/index.html
  • 56. PUBLIC PRESENTATION | CLAUS IBSEN56 Riding Camel ● More examples ... ... and further details at website. http://camel.apache.org/examples
  • 57. PUBLIC PRESENTATION | CLAUS IBSEN57 Agenda ● What is Apache Camel? ● A little Example ● Riding Camel ● Creating new Camel Projects ● hawtio ● Q & A
  • 58. PUBLIC PRESENTATION | CLAUS IBSEN58 Creating new Camel Projects ● Using Command Shell ● .. or from Eclipse
  • 59. PUBLIC PRESENTATION | CLAUS IBSEN59 Creating new Camel Projects ● Importing into Eclipse Existing Maven Project
  • 60. PUBLIC PRESENTATION | CLAUS IBSEN60 Creating new Camel Projects ● Maven Archetypes camel-archetype-activemq camel-archetype-java camel-archetype-blueprint camel-archetype-scala camel-archetype-component camel-archetype-spring camel-archetype-dataformat camel-archetype-spring-dm camel-archetype-groovy camel-archetype-web
  • 61. PUBLIC PRESENTATION | CLAUS IBSEN61 Creating new Camel Projects ● camel-archetype-groovy mvn install mvn exec:java
  • 62. PUBLIC PRESENTATION | CLAUS IBSEN62 Creating new Camel Projects ● camel-archetype-spring mvn install mvn camel:run mvn io.hawt:hawtio-maven-plugin:1.4.2:spring
  • 63. PUBLIC PRESENTATION | CLAUS IBSEN63 Agenda ● What is Apache Camel? ● A little Example ● Riding Camel ● Creating new Camel Projects ● hawtio ● Q & A
  • 64. PUBLIC PRESENTATION | CLAUS IBSEN64 hawtio ● What does it do? ...
  • 65. PUBLIC PRESENTATION | CLAUS IBSEN65 hawtio ● Yet another awesome project created by this guy ...
  • 66. PUBLIC PRESENTATION | CLAUS IBSEN66 hawtio Tooling – Web Console - hawtio http://hawt.io
  • 67. PUBLIC PRESENTATION | CLAUS IBSEN67 hawtio ● What does it do for Apache Camel?
  • 68. PUBLIC PRESENTATION | CLAUS IBSEN68 hawtio ● Technology Stack ● HTML5 single page app ● TypeScript → JavaScript ● Angular JS ● Bootstrap CSS ● HTTP/REST ↔ backend ● Jolokia on backend for JMX over REST ● Plugins expose services as JMX or REST http://hawt.io/plugins/howPluginsWork.html
  • 69. PUBLIC PRESENTATION | CLAUS IBSEN69 Apache Camel & hawtio
  • 70. PUBLIC PRESENTATION | CLAUS IBSEN70 Agenda ● What is Apache Camel? ● A little Example ● Riding Camel ● Creating new Camel Projects ● hawtio ● Q & A
  • 71. PUBLIC PRESENTATION | CLAUS IBSEN71 These three awesome has something in common
  • 72. PUBLIC PRESENTATION | CLAUS IBSEN72 These three awesome has something in common
  • 73. PUBLIC PRESENTATION | CLAUS IBSEN73 What about a 4th awesome project?
  • 74. PUBLIC PRESENTATION | CLAUS IBSEN74 Any Questions ? ● Contact ● EMail: cibsen@redhat.com / claus.ibsen@gmail.com ● Twitter: @davsclaus ● Blog: http://davsclaus.com ● Linkedin: http://www.linkedin.com/in/davsclaus