Elegant Systems Integration
    with Apache Camel
       Pradeep Elankumaran
           Intridea, Inc.
       pradeep@intr...
About Us

❖   Intridea is a high-end web consulting shop

❖   Based out of Washington DC, but dispersed all over the
    U...
What’s the Problem?

❖   Most web applications require a suite of supporting services

    ❖   ex: email queue, RSS import...
What is Apache Camel?
                        (marketing-speak)




❖   Message-Oriented Middleware

❖   Rule-based messag...
What is Apache Camel?
                              (plain-speak)


❖   a Routing Engine

❖   Provides you pluggable Compo...
A Few Code Examples
A Basic Camel Route

              from the ‘EmailQueue’ ActiveMQ queue


from(“active-mq:queue:/EmailQueue”).
  to(“smtp:...
A Bit More Advanced...
                                                    throttle the queue
                            ...
A Long-Running Route

                from the reddit.com RSS feed


     from(“rss:http://reddit.com/.rss?splitEntries=tr...
Camel is Powerful.
Component List
ActiveMQ    Freemarker      JPA         RMI     StringTemplate
 AMQP           FTP       JT/400       RNC  ...
Can hook up most of these
components with each other.
Camel allows you to be
 data-format agnostic
Can add new, custom
components very easily
Camel integrates with Spring
      using an XML/POJO based Spring DSL
Robust Error-Handling DSL

 errorHandler(defaultErrorHandler().
 	 maximumRedeliveries(2).
    backOffMultiplier(2).
 	 re...
A Real-World Case Study
       Present.ly
What is Present.ly?

❖   Enterprise Micro-blogging platform

❖   Written in Ruby on Rails

❖   A pretty big XMPP component...
Pre-Camel Architecture
               Rails                     eJabberd (XMPP)


                                        ...
Present.ly w/ Camel
                                       eJabberd (XMPP)


 Rails                                 Notifs...
Easy to setup
Shared-Nothing
 app instances
Camel in Detail
All Camel code runs inside a
      CamelContext
                                Type
 Components                   Convert...
Most of the components are
 backed by stable, best-of-
    breed Java libraries
Processing and Filtering
 messages is very easy
One Final Example
import   org.apache.activemq.camel.component.ActiveMQComponent;
import   org.apache.camel.CamelContext;
...
Learn more...
Enterprise Integration
            Patterns (EIP)
❖   Many recipes for common integration issues

❖   Excellent book by Gr...
Examples of EIP Patterns
Examples of EIP Patterns
Learning More Camel

❖   Website is very comprehensive

❖   Downloadable Manual
❖   Mailing lists are handy

❖   Email me!...
Questions?
      Reach me at
pradeep@intridea.com
     @pradeep24
Something new...
Llama

❖   A port of Camel to Ruby

❖   based off EventMachine, so it runs ROCK SOLID

❖   early alpha at this point, looki...
Llama Code Example
github.com/skyfallsin/llama
Upcoming SlideShare
Loading in...5
×

Elegant Systems Integration w/ Apache Camel

5,288

Published on

first given at Confoo.ca

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

No Downloads
Views
Total Views
5,288
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
55
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide












  • Note that components are initialized by a URI - this is very camel-specific.
    each component has it’s own URI and there are over 50 components
    API contains a list of components with their URI schemes






  • Some of these components are read-only, some are long-running, some are not.


  • can pass around any kind of message in any data format. only marshal/unmarshal when oyu need to
  • too many moving parts to show, but you can setup a new component in ~ 20 minutes or so










  • our customers love it, most of have already invested in services to manage java daemons






  • HTTP posts are backed by Mina, mail backed by JavaMail, etc
  • you will extend some really good camel default classes


















  • want to get rid of these


  • Elegant Systems Integration w/ Apache Camel

    1. 1. Elegant Systems Integration with Apache Camel Pradeep Elankumaran Intridea, Inc. pradeep@intridea.com @pradeep24
    2. 2. About Us ❖ Intridea is a high-end web consulting shop ❖ Based out of Washington DC, but dispersed all over the United States ❖ Our most popular product is Presently, an enterprise microblogging platform ❖ Specialize in development using Ruby, Rails, Java, Erlang and beyond
    3. 3. What’s the Problem? ❖ Most web applications require a suite of supporting services ❖ ex: email queue, RSS import, notification emails, etc. ❖ Many great libraries, but hard to identify best-of-breed ❖ Effort required to stitch together custom supporting services and backends for every new site
    4. 4. What is Apache Camel? (marketing-speak) ❖ Message-Oriented Middleware ❖ Rule-based message routing ❖ Message mediation engine ❖ Apache 2 License
    5. 5. What is Apache Camel? (plain-speak) ❖ a Routing Engine ❖ Provides you pluggable Components ex: JMS, RSS, SMTP, IMAP, XMPP ❖ Can define chains of components, allowing messages to flow from one component to another - routes. ❖ Can convert messages from one format to another within these routes ❖ Very extensible - can add your own app-specific components ❖ Very fast & lean
    6. 6. A Few Code Examples
    7. 7. A Basic Camel Route from the ‘EmailQueue’ ActiveMQ queue from(“active-mq:queue:/EmailQueue”). to(“smtp://user@smtp.intridea.com? password=mypassword&to=pradeep@intridea.com”) deliver directly to pradeep@intridea.com via SMTP
    8. 8. A Bit More Advanced... throttle the queue to 10 XMPP stanzas every 20 seconds from(“active-mq:queue:/XMPPQueue”). converts JSON from the throttle(10).timePeriodMillis(20000). queue to a XMPP message unmarshal().json(JsonLibrary.JACKSON). using the Jackson JSON library to(“xmpp://pradeep@jabber.org/? room=krypton@conference.jabber.org&password=secret”) send every message to the ‘krypton’ chat room via XMPP on the jabber.org server
    9. 9. A Long-Running Route from the reddit.com RSS feed from(“rss:http://reddit.com/.rss?splitEntries=true”). marshal().rss(). filter().xpath(“//item/title[contains(., ‘Montreal’)]”). process(new MyCustomRSSProcessor()). to(“mina:tcp://mywebapp.com/postToApp”) run matched messages through a filter messages by XPath custom processor that converts to your special data format POSTs final message to this URL
    10. 10. Camel is Powerful.
    11. 11. Component List ActiveMQ Freemarker JPA RMI StringTemplate AMQP FTP JT/400 RNC TCP Atom GHttp LDAP RNG Test Bean GTask Log RSS Timer Browse GMail Mail SEDA UDP Cache Hibernate MINA SERVLET Validation Cometd HL7 Mock SFTP Velocity CXF HTTP MSV Smooks VM CXFRS IMAP Multicast SMTP XMPP DataSet IRC NMR SNMP XQuery Direct JavaSpace POP Spring XSLT Esper JBI Printer SQL Event JCR Quartz Stream File JDBC Quickfix Flatpack Jetty Ref JMS Restlet
    12. 12. Can hook up most of these components with each other.
    13. 13. Camel allows you to be data-format agnostic
    14. 14. Can add new, custom components very easily
    15. 15. Camel integrates with Spring using an XML/POJO based Spring DSL
    16. 16. Robust Error-Handling DSL errorHandler(defaultErrorHandler(). maximumRedeliveries(2). backOffMultiplier(2). retryAttemptedLogLevel(LoggingLevel.WARN)); onException(IOException.class). maximumRedeliveries(3). redeliverDelay(1000);
    17. 17. A Real-World Case Study Present.ly
    18. 18. What is Present.ly? ❖ Enterprise Micro-blogging platform ❖ Written in Ruby on Rails ❖ A pretty big XMPP component for message delivery ❖ Requires a lot of supporting architecture/daemons
    19. 19. Pre-Camel Architecture Rails eJabberd (XMPP) Notifs Processor Email Sender Queue RUBY Daily Digests IMAP Processor IM Gateway multiple ruby daemons we had to manage
    20. 20. Present.ly w/ Camel eJabberd (XMPP) Rails Notifs Processor STOMP protocol Email Sender ActiveMQ Camel JAVA Daily Digests IMAP Processor IM Gateway one easy-to-deploy .jar file, can easily interface with Feed Fetcher different architectures
    21. 21. Easy to setup Shared-Nothing app instances
    22. 22. Camel in Detail
    23. 23. All Camel code runs inside a CamelContext Type Components Converters Endpoints CamelContext Data Formats Routes Languages
    24. 24. Most of the components are backed by stable, best-of- breed Java libraries
    25. 25. Processing and Filtering messages is very easy
    26. 26. One Final Example import org.apache.activemq.camel.component.ActiveMQComponent; import org.apache.camel.CamelContext; import org.apache.camel.Exchange; import org.apache.camel.Processor; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.impl.DefaultCamelContext; public class MyCamelRouter { public static void main(String args[]) throws Exception { // initialize a new CamelContext CamelContext context = new DefaultCamelContext(); // attach the ActiveMQ component context.addComponent("active-mq", ActiveMQComponent.activeMQComponent("tcp://localhost:81816")); context.addRoutes(new RouteBuilder(){ public void configure() { // setup a new route from("active-mq:queue:/MyRandomQueue"). throttle(5).timePeriodMillis(10000). process(new Processor() { public void process(Exchange exchange) { System.out.println("RECV: "+exchange.getIn().getBody(String.class)); } }).to("mina:tcp://mywebsite.com/"); } }); } }
    27. 27. Learn more...
    28. 28. Enterprise Integration Patterns (EIP) ❖ Many recipes for common integration issues ❖ Excellent book by Gregor Hohpe and Bobby Woolf ❖ Camel formalizes the language for a very big subset of the patterns listed in this book ❖ Leverage the patterns to create scalable architectures for your application using the tools Camel gives you.
    29. 29. Examples of EIP Patterns
    30. 30. Examples of EIP Patterns
    31. 31. Learning More Camel ❖ Website is very comprehensive ❖ Downloadable Manual ❖ Mailing lists are handy ❖ Email me! pradeep@intridea.com ❖ Camel in Action by Claus Ibsen, Jonathan Anstey & Hadrian Zbarcea
    32. 32. Questions? Reach me at pradeep@intridea.com @pradeep24
    33. 33. Something new...
    34. 34. Llama ❖ A port of Camel to Ruby ❖ based off EventMachine, so it runs ROCK SOLID ❖ early alpha at this point, looking for helpers ❖ github.com/skyfallsin/llama
    35. 35. Llama Code Example
    36. 36. github.com/skyfallsin/llama
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×