Camel and JBoss
-
Upload
jbug-italy -
Category
Technology
-
view
2.410 -
download
4
description
Transcript of Camel and JBoss
1
Implementing Enterprise Integration Patterns through Apache Camel
Andrea Leoncini, Red Hat
lunedì 18 febbraio 13
Copyright © 2013 Red Hat, Inc. All rights reserved.
Your speaker today
Andrea Leoncini• [email protected]• 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
lunedì 18 febbraio 13
Copyright © 2013 Red Hat, Inc. All rights reserved.
What are Enterprise Integration Patterns?
3
lunedì 18 febbraio 13
Copyright © 2013 Red Hat, Inc. All rights reserved.
Book by Gregor & Bobby!
4
lunedì 18 febbraio 13
Copyright © 2013 Red Hat, Inc. All rights reserved.
A selection of some of the patterns...
5
lunedì 18 febbraio 13
Copyright © 2013 Red Hat, Inc. All rights reserved.
What is Apache Camel?
http://camel.apache.org/
6
lunedì 18 febbraio 13
Copyright © 2013 Red Hat, Inc. All rights reserved.
What is Apache Camel?
7
Apache Camel is a Powerful Open Source
Integration Frameworkbased on known
Enterprise Integration Patterns
http://camel.apache.org/enterprise-integration-patterns.html
lunedì 18 febbraio 13
Copyright © 2013 Red Hat, Inc. All rights reserved.
Lets look at a pattern!
8
lunedì 18 febbraio 13
Copyright © 2013 Red Hat, Inc. All rights reserved.
Message Filter
9
lunedì 18 febbraio 13
<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>
Copyright © 2013 Red Hat, Inc. All rights reserved.
Message Filter : XML
10
lunedì 18 febbraio 13
<?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>
Copyright © 2013 Red Hat, Inc. All rights reserved.
Message Filter : Spring XML
11
lunedì 18 febbraio 13
<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>
Copyright © 2013 Red Hat, Inc. All rights reserved.
Message Filter : XML
12
lunedì 18 febbraio 13
Copyright © 2013 Red Hat, Inc. All rights reserved.
Expressions & Predicates
13
15 ExpressionLanguages BeanShell Python
EL RubyGroovy Simple
JavaScript SpELJSR 223 SQLOGNL XPathMVEL XQueryPHP
lunedì 18 febbraio 13
Copyright © 2013 Red Hat, Inc. All rights reserved.
URIs, Endpoints and Components (120+)
14
http://camel.apache.org/components.html
activemq cxf flatpack jasyptactivemq-journal cxfrs freemarker javaspace
amqp dataset ftp/ftps/sftp jbiatom db4o gae jcrbean direct hdfs jdbc
bean validation ejb hibernate jettybrowse esper hl7 jmscache event http jmx
cometd exec ibatis jpacrypto file irc jt/400
lunedì 18 febbraio 13
Copyright © 2013 Red Hat, Inc. All rights reserved.
120+ components...
15
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
lunedì 18 febbraio 13
<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>
Copyright © 2013 Red Hat, Inc. All rights reserved.
Message Filter : XML
16
lunedì 18 febbraio 13
Copyright © 2013 Red Hat, Inc. All rights reserved.
Message Filter : Java
from("activemq:topic:Quotes”). filter().xpath("/quote/product = ‘widget’"). to("mqseries:WidgetQuotes");
17
lunedì 18 febbraio 13
Copyright © 2013 Red Hat, Inc. All rights reserved.
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
lunedì 18 febbraio 13
Copyright © 2013 Red Hat, Inc. All rights reserved.
Message Filter : Scala
"direct:a" when(_.in == "<hello/>") { to("mock:a")}
19
lunedì 18 febbraio 13
<camelContext xmlns="http://camel.apache.org/schema/spring"> <package>com.acme.quotes</package></camelContext>
Copyright © 2013 Red Hat, Inc. All rights reserved.
Create CamelContext in Spring
20
lunedì 18 febbraio 13
CamelContext context = new DefaultCamelContext();context.addRoutes(new MyRouteBuilder());context.start();
Copyright © 2013 Red Hat, Inc. All rights reserved.
Create CamelContext in Java
21
lunedì 18 febbraio 13
Copyright © 2013 Red Hat, Inc. All rights reserved.
IDE support
lunedì 18 febbraio 13
Copyright © 2013 Red Hat, Inc. All rights reserved.
IDE support (XML)
23
lunedì 18 febbraio 13
Copyright © 2013 Red Hat, Inc. All rights reserved.
Recap - core concepts of Camel
24
Enterprise Integration Patterns Routing Domain Specific Language (DSL) Endpoints & URIs Predicates & Expressions Components (lots of ‘em!) Test Kit
and much more ...
lunedì 18 febbraio 13
Copyright © 2013 Red Hat, Inc. All rights reserved.
Beans
25
lunedì 18 febbraio 13
Copyright © 2013 Red Hat, Inc. All rights reserved.
Bean as a Message Translator
from("activemq:Incoming”). beanRef("myBeanName”, “someMethod"). to("activemq:Outgoing");
26
lunedì 18 febbraio 13
Copyright © 2013 Red Hat, Inc. All rights reserved.
Bean
public class Foo {
public String someMethod(String name) { return “Hello “ + name; }}
27
lunedì 18 febbraio 13
public class Foo {
@Consume(uri="activemq:cheese") public Object onCheese(String name) { ... }}
Copyright © 2013 Red Hat, Inc. All rights reserved.
Binding Beans to Camel Endpoints
28
lunedì 18 febbraio 13
public class Foo {
public Object onCheese( @XPath("/foo/bar") String name, @Header("JMSCorrelationID") String id) { ... }}
Copyright © 2013 Red Hat, Inc. All rights reserved.
Binding Method Arguments
for more annotations seehttp://camel.apache.org/bean-integration.html
29
lunedì 18 febbraio 13
public class Foo { @Produce(uri="activemq:foo.bar") ProducerTemplate producer;
public void doSomething() { if (whatever) { producer.sendBody("<hello>world!</hello>"); } }}
Copyright © 2013 Red Hat, Inc. All rights reserved.
Sending messages to endpoints
30
lunedì 18 febbraio 13
Copyright © 2013 Red Hat, Inc. All rights reserved.
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
lunedì 18 febbraio 13