Successfully reported this slideshow.
Implementing Enterprise Integration     Patterns through Apache Camel    Andrea Leoncini, Red Hat     1lunedì 18 febbraio 13
Your speaker today      Andrea Leoncini            • andrea.leoncini@redhat.com            • twitter: @leopericoli      ...
What are Enterprise Integration Patterns?      3      Copyright © 2013 Red Hat, Inc. All rights reserved.lunedì 18 febbrai...
Book by Gregor & Bobby!      4      Copyright © 2013 Red Hat, Inc. All rights reserved.lunedì 18 febbraio 13
A selection of some of the patterns...      5      Copyright © 2013 Red Hat, Inc. All rights reserved.lunedì 18 febbraio 13
What is Apache Camel?                                                        http://camel.apache.org/      6      Copyrigh...
What is Apache Camel?                        Apache Camel is a Powerful Open                                     Source   ...
Lets look at a pattern!      8      Copyright © 2013 Red Hat, Inc. All rights reserved.lunedì 18 febbraio 13
Message Filter      9      Copyright © 2013 Red Hat, Inc. All rights reserved.lunedì 18 febbraio 13
Message Filter : XML             <camelContext xmlns="http://camel.apache.org/schema/spring">               <route>       ...
Message Filter : Spring XML          <?xml version="1.0" encoding="UTF-8"?>          <beans xmlns="http://www.springframew...
Message Filter : XML             <camelContext xmlns="http://camel.apache.org/schema/spring">               <route>       ...
Expressions & Predicates            15 Expression            Languages                                              BeanSh...
URIs, Endpoints and Components (120+)                              http://camel.apache.org/components.html                ...
120+ components...                           language                        properties          seda               stream...
Message Filter : XML             <camelContext xmlns="http://camel.apache.org/schema/spring">               <route>       ...
Message Filter : Java      from("activemq:topic:Quotes”).        filter().xpath("/quote/product = ‘widget’").          to(...
Message Filter : Java Complete     package com.acme.quotes;     import org.apache.camel.builder.RouteBuilder;     public c...
Message Filter : Scala                   "direct:a" when(_.in == "<hello/>") {                       to("mock:a")         ...
Create CamelContext in Spring    <camelContext xmlns="http://camel.apache.org/schema/spring">      <package>com.acme.quote...
Create CamelContext in Java           CamelContext context = new DefaultCamelContext();           context.addRoutes(new My...
IDE support             Copyright © 2013 Red Hat, Inc. All rights reserved.lunedì 18 febbraio 13
IDE support (XML)     23      Copyright © 2013 Red Hat, Inc. All rights reserved.lunedì 18 febbraio 13
Recap - core concepts of Camel         Enterprise Integration Patterns         Routing         Domain Specific Language...
Beans     25      Copyright © 2013 Red Hat, Inc. All rights reserved.lunedì 18 febbraio 13
Bean as a Message Translator          from("activemq:Incoming”).            beanRef("myBeanName”, “someMethod").          ...
Bean     public class Foo {           public String someMethod(String name) {             return “Hello “ + name;         ...
Binding Beans to Camel Endpoints          public class Foo {               @Consume(uri="activemq:cheese")               p...
Binding Method Arguments          public class Foo {               public Object onCheese(                 @XPath("/foo/ba...
Sending messages to endpoints  public class Foo {    @Produce(uri="activemq:foo.bar")    ProducerTemplate producer;       ...
Sending messages to endpoints    public interface MyListener {        String sayHello(String name);    }    public class M...
Upcoming SlideShare
Loading in …5
×

Camel and JBoss

2,602 views

Published on

Camel and JBoss
Andrea Leoncini
JBug Roma - Febraury 2013

Published in: Technology
  • Be the first to comment

Camel and JBoss

  1. 1. Implementing Enterprise Integration Patterns through Apache Camel Andrea Leoncini, Red Hat 1lunedì 18 febbraio 13
  2. 2. Your speaker today  Andrea Leoncini • andrea.leoncini@redhat.com • twitter: @leopericoli  Senior Middleware Solution Architect at Red Hat • leaders in open source middleware & integration • we provide training, consulting, support, distributions & tools for open source integration software  In the community • co-founder of JUG Roma • co-founder of JBUG Roma, JBUG Milano • andrea.leoncini @JBoss Community • pride founder of JBoss Consulting Team in Italy 2 Copyright © 2013 Red Hat, Inc. All rights reserved.lunedì 18 febbraio 13
  3. 3. What are Enterprise Integration Patterns? 3 Copyright © 2013 Red Hat, Inc. All rights reserved.lunedì 18 febbraio 13
  4. 4. Book by Gregor & Bobby! 4 Copyright © 2013 Red Hat, Inc. All rights reserved.lunedì 18 febbraio 13
  5. 5. A selection of some of the patterns... 5 Copyright © 2013 Red Hat, Inc. All rights reserved.lunedì 18 febbraio 13
  6. 6. What is Apache Camel? http://camel.apache.org/ 6 Copyright © 2013 Red Hat, Inc. All rights reserved.lunedì 18 febbraio 13
  7. 7. What is Apache Camel? Apache Camel is a Powerful Open Source Integration Framework based on known Enterprise Integration Patterns http://camel.apache.org/enterprise-integration-patterns.html 7 Copyright © 2013 Red Hat, Inc. All rights reserved.lunedì 18 febbraio 13
  8. 8. Lets look at a pattern! 8 Copyright © 2013 Red Hat, Inc. All rights reserved.lunedì 18 febbraio 13
  9. 9. Message Filter 9 Copyright © 2013 Red Hat, Inc. All rights reserved.lunedì 18 febbraio 13
  10. 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.lunedì 18 febbraio 13
  11. 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.lunedì 18 febbraio 13
  12. 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.lunedì 18 febbraio 13
  13. 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.lunedì 18 febbraio 13
  14. 14. URIs, Endpoints and Components (120+) http://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.lunedì 18 febbraio 13
  15. 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.lunedì 18 febbraio 13
  16. 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.lunedì 18 febbraio 13
  17. 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.lunedì 18 febbraio 13
  18. 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.lunedì 18 febbraio 13
  19. 19. Message Filter : Scala "direct:a" when(_.in == "<hello/>") { to("mock:a") } 19 Copyright © 2013 Red Hat, Inc. All rights reserved.lunedì 18 febbraio 13
  20. 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.lunedì 18 febbraio 13
  21. 21. Create CamelContext in Java CamelContext context = new DefaultCamelContext(); context.addRoutes(new MyRouteBuilder()); context.start(); 21 Copyright © 2013 Red Hat, Inc. All rights reserved.lunedì 18 febbraio 13
  22. 22. IDE support Copyright © 2013 Red Hat, Inc. All rights reserved.lunedì 18 febbraio 13
  23. 23. IDE support (XML) 23 Copyright © 2013 Red Hat, Inc. All rights reserved.lunedì 18 febbraio 13
  24. 24. Recap - core concepts of Camel  Enterprise Integration Patterns  Routing  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.lunedì 18 febbraio 13
  25. 25. Beans 25 Copyright © 2013 Red Hat, Inc. All rights reserved.lunedì 18 febbraio 13
  26. 26. Bean as a Message Translator from("activemq:Incoming”). beanRef("myBeanName”, “someMethod"). to("activemq:Outgoing"); 26 Copyright © 2013 Red Hat, Inc. All rights reserved.lunedì 18 febbraio 13
  27. 27. Bean public class Foo { public String someMethod(String name) { return “Hello “ + name; } } 27 Copyright © 2013 Red Hat, Inc. All rights reserved.lunedì 18 febbraio 13
  28. 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.lunedì 18 febbraio 13
  29. 29. Binding Method Arguments public class Foo { public Object onCheese( @XPath("/foo/bar") String name, @Header("JMSCorrelationID") String id) { ... } } for more annotations see http://camel.apache.org/bean-integration.html 29 Copyright © 2013 Red Hat, Inc. All rights reserved.lunedì 18 febbraio 13
  30. 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.lunedì 18 febbraio 13
  31. 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.lunedì 18 febbraio 13

×