Your SlideShare is downloading. ×
Easy Integration with Apache Camel and Fuse IDE
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

Easy Integration with Apache Camel and Fuse IDE

4,148
views

Published on

The talk presented by James Strachan (Red Hat) on the 6th of March 2013 at the London JBoss USer Group event. …

The talk presented by James Strachan (Red Hat) on the 6th of March 2013 at the London JBoss USer Group event.
Visit London JBUG on Meetup http://www.meetup.com/JBoss-User-Group/

Published in: Technology

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

No Downloads
Views
Total Views
4,148
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
0
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. Implemen(ng  Enterprise  Integra(on   Pa3erns  through  Apache  Camel   James  Strachan,  Red  Hat 1Friday, February 8, 2013
  • 2. Your  speaker  today  James  Strachan • jstrachan@redhat.com • twi8er:  @jstrachan • blog:  h8p://macstrac.blogspot.com/  Senior  Consul(ng  SoFware  Engineer  at  Red  Hat • leaders  in  open  source  middleware  &  integra?on • we  provide  training,  consul?ng,  support,  distribu?ons  &  tools  for  open   source  integra?on  soCware  Open  Source  hacker • created  the  Groovy  programming  language • created  Apache  Camel • co-­‐founder  of – Apache  Ac(veMQ,  ServiceMix,  Geronimo – Scalate • lets  not  men?on  Jelly  :) 2 Copyright  ©  2013  Red  Hat,  Inc.  All  rights  reserved.  Friday, February 8, 2013
  • 3. What  are  Enterprise  Integra?on  Pa8erns? 3 Copyright  ©  2013  Red  Hat,  Inc.  All  rights  reserved.  Friday, February 8, 2013
  • 4. Book  by  Gregor  &  Bobby! 4 Copyright  ©  2013  Red  Hat,  Inc.  All  rights  reserved.  Friday, February 8, 2013
  • 5. A  selec?on  of  some  of  the  pa8erns... 5 Copyright  ©  2013  Red  Hat,  Inc.  All  rights  reserved.  Friday, February 8, 2013
  • 6. What  is  Apache  Camel? http://camel.apache.org/ 6 Copyright  ©  2013  Red  Hat,  Inc.  All  rights  reserved.  Friday, February 8, 2013
  • 7. What  is  Apache  Camel? Apache  Camel  is  a  Powerful  Open  Source Integra(on  Framework based  on  known Enterprise  Integra(on  Pa3erns   h3p://camel.apache.org/enterprise-­‐integra(on-­‐pa3erns.html 7 Copyright  ©  2013  Red  Hat,  Inc.  All  rights  reserved.  Friday, February 8, 2013
  • 8. Lets  look  at  a  pa8ern! 8 Copyright  ©  2013  Red  Hat,  Inc.  All  rights  reserved.  Friday, February 8, 2013
  • 9. Message  Filter 9 Copyright  ©  2013  Red  Hat,  Inc.  All  rights  reserved.  Friday, February 8, 2013
  • 10. Message  Filter  :  XML <camelContext xmlns="http://camel.apache.org/schema/spring"> <route> <from uri="activemq:topic:Quotes"/> <filter> <xpath>/quote/product = ‘widget’</xpath> <to uri="mqseries:WidgetQuotes"/> </filter> </route> </camelContext> 10 Copyright  ©  2013  Red  Hat,  Inc.  All  rights  reserved.  Friday, February 8, 2013
  • 11. Message  Filter  :  Spring  XML <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd"> <camelContext xmlns="http://camel.apache.org/schema/spring"> <route> <from uri="activemq:topic:Quotes"/> <filter> <xpath>/quote/product = ‘widget’</xpath> <to uri="mqseries:WidgetQuotes"/> </filter> </route> </camelContext> </beans> 11 Copyright  ©  2013  Red  Hat,  Inc.  All  rights  reserved.  Friday, February 8, 2013
  • 12. Message  Filter  :  XML <camelContext xmlns="http://camel.apache.org/schema/spring"> <route> <from uri="activemq:topic:Quotes"/> <filter> <xpath>/quote/product = ‘widget’</xpath> <to uri="mqseries:WidgetQuotes"/> </filter> </route> </camelContext> 12 Copyright  ©  2013  Red  Hat,  Inc.  All  rights  reserved.  Friday, February 8, 2013
  • 13. Expressions  &  Predicates 15 Expression Languages BeanShell Python EL Ruby Groovy Simple JavaScript SpEL JSR 223 SQL OGNL XPath MVEL XQuery PHP 13 Copyright  ©  2013  Red  Hat,  Inc.  All  rights  reserved.  Friday, February 8, 2013
  • 14. URIs,  Endpoints  and  Components  (120+) h8p://camel.apache.org/components.html activemq cxf flatpack jasypt activemq-journal cxfrs freemarker javaspace amqp dataset ftp/ftps/sftp jbi atom db4o gae jcr bean direct hdfs jdbc bean validation ejb hibernate jetty browse esper hl7 jms cache event http jmx cometd exec ibatis jpa crypto file irc jt/400 14 Copyright  ©  2013  Red  Hat,  Inc.  All  rights  reserved.  Friday, February 8, 2013
  • 15. 120+  components... language properties seda stream ldap quartz servlet string-template mail/imap/pop3 quickfix sip test mina ref smooks timer mock restlet smpp validation msv rmi snmp velocity nagios rnc spring-integration vm netty rng spring-security xmpp nmr rss spring-ws xquery printer scalate sql xslt 15 Copyright  ©  2013  Red  Hat,  Inc.  All  rights  reserved.  Friday, February 8, 2013
  • 16. Message  Filter  :  XML <camelContext xmlns="http://camel.apache.org/schema/spring"> <route> <from uri="activemq:topic:Quotes"/> <filter> <xpath>/quote/product = ‘widget’</xpath> <to uri="mqseries:WidgetQuotes"/> </filter> </route> </camelContext> 16 Copyright  ©  2013  Red  Hat,  Inc.  All  rights  reserved.  Friday, February 8, 2013
  • 17. Message  Filter  :  Java from("activemq:topic:Quotes”). filter().xpath("/quote/product = ‘widget’"). to("mqseries:WidgetQuotes"); 17 Copyright  ©  2013  Red  Hat,  Inc.  All  rights  reserved.  Friday, February 8, 2013
  • 18. Message  Filter  :  Java  Complete package com.acme.quotes; import org.apache.camel.builder.RouteBuilder; public class MyRouteBuilder extends RouteBuilder { public void configure() { // forward widget quotes to MQSeries from("activemq:topic:Quotes”). filter().xpath("/quote/product = ‘widget’"). to("mqseries:WidgetQuotes"); } } 18 Copyright  ©  2013  Red  Hat,  Inc.  All  rights  reserved.  Friday, February 8, 2013
  • 19. Message  Filter  :  Scala   "direct:a" when(_.in == "<hello/>") { to("mock:a") } 19 Copyright  ©  2013  Red  Hat,  Inc.  All  rights  reserved.  Friday, February 8, 2013
  • 20. Create  CamelContext  in  Spring <camelContext xmlns="http://camel.apache.org/schema/spring"> <package>com.acme.quotes</package> </camelContext> 20 Copyright  ©  2013  Red  Hat,  Inc.  All  rights  reserved.  Friday, February 8, 2013
  • 21. Create  CamelContext  in  Java CamelContext context = new DefaultCamelContext(); context.addRoutes(new MyRouteBuilder()); context.start(); 21 Copyright  ©  2013  Red  Hat,  Inc.  All  rights  reserved.  Friday, February 8, 2013
  • 22. IDE  support Copyright  ©  2013  Red  Hat,  Inc.  All  rights  reserved.  Friday, February 8, 2013
  • 23. IDE  support  (XML) 23 Copyright  ©  2013  Red  Hat,  Inc.  All  rights  reserved.  Friday, February 8, 2013
  • 24. Recap  -­‐  core  concepts  of  Camel  Enterprise  Integra(on  Pa3erns  Rou(ng  Domain  Specific  Language  (DSL)  Endpoints  &  URIs  Predicates  &  Expressions  Components  (lots  of  ‘em!)  Test  Kit               and  much  more  ... 24 Copyright  ©  2013  Red  Hat,  Inc.  All  rights  reserved.  Friday, February 8, 2013
  • 25. Beans 25 Copyright  ©  2013  Red  Hat,  Inc.  All  rights  reserved.  Friday, February 8, 2013
  • 26. Bean  as  a  Message  Translator from("activemq:Incoming”). beanRef("myBeanName”, “someMethod"). to("activemq:Outgoing"); 26 Copyright  ©  2013  Red  Hat,  Inc.  All  rights  reserved.  Friday, February 8, 2013
  • 27. Bean   public class Foo { public String someMethod(String name) { return “Hello “ + name; } } 27 Copyright  ©  2013  Red  Hat,  Inc.  All  rights  reserved.  Friday, February 8, 2013
  • 28. Binding  Beans  to  Camel  Endpoints public class Foo { @Consume(uri="activemq:cheese") public Object onCheese(String name) { ... } } 28 Copyright  ©  2013  Red  Hat,  Inc.  All  rights  reserved.  Friday, February 8, 2013
  • 29. Binding  Method  Arguments public class Foo { public Object onCheese( @XPath("/foo/bar") String name, @Header("JMSCorrelationID") String id) { ... } } for  more  annota(ons  see h3p://camel.apache.org/bean-­‐integra(on.html 29 Copyright  ©  2013  Red  Hat,  Inc.  All  rights  reserved.  Friday, February 8, 2013
  • 30. Sending  messages  to  endpoints public class Foo { @Produce(uri="activemq:foo.bar") ProducerTemplate producer; public void doSomething() { if (whatever) { producer.sendBody("<hello>world!</hello>"); } } } 30 Copyright  ©  2013  Red  Hat,  Inc.  All  rights  reserved.  Friday, February 8, 2013
  • 31. Sending  messages  to  endpoints public interface MyListener { String sayHello(String name); } public class MyBean { @Produce(uri = "activemq:foo") protected MyListener producer; public void doSomething() { // lets send a message String response = producer.sayHello("James"); } } 31 Copyright  ©  2013  Red  Hat,  Inc.  All  rights  reserved.  Friday, February 8, 2013
  • 32. Fastest  way  to  learn....  Manning  top-­‐15  year  to  date  (2010) #10 #12 Copyright  ©  2013  Red  Hat,  Inc.  All  rights  reserved.  Friday, February 8, 2013
  • 33. Fuse  IDE:  the  fastest  way  to  get  riding!  free  eclipse  based  tool  for  Apache  Camel  &  Ac(veMQ  etc • create  projects,  edit  routes,  run  stuff,  visualise,  trace  &  diagnose h3p://fusesource.com/ 33 Copyright  ©  2013  Red  Hat,  Inc.  All  rights  reserved.  Friday, February 8, 2013
  • 34. Summary:  Camel  rocks  Ride  that  Camel • h8p://camel.apache.org/  Download  Fuse  IDE • h8p://fusesource.com  Buy  the  book!    Don’t  get  the  hump! 34 Copyright  ©  2013  Red  Hat,  Inc.  All  rights  reserved.  Friday, February 8, 2013
  • 35. Any  Ques(ons? twi3er:  @jstrachan  #fusenews h3p://fusesource.com 35 Copyright  ©  2013  Red  Hat,  Inc.  All  rights  reserved.  Friday, February 8, 2013