Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Camel as a_glue

2,327 views

Published on

  • Be the first to comment

Camel as a_glue

  1. 1. Camelas a Glue
  2. 2. Project. How we planned it
  3. 3. Project. How we imagine it.
  4. 4. Project. In practice.
  5. 5. Integration project. In practice.
  6. 6. How to handle it?
  7. 7. RTFM.Enterprise Integration Patterns: Designing, Building, and Deploying Messaging Solutions
  8. 8. Specific tool• Apache Camel• Spring Integration• Enterprise Service Bus (Mule ESB) Read article
  9. 9. Apache Camel. Pros.Pros• Lighweight• A lot components• Support many Data Formats• Good community• DSL(XML, Java, Scala, Groovy)• Spring integration
  10. 10. Apache Camel. Cons.• Messy documentations
  11. 11. Basic example. XML DSLcamel-config.xml<camelContext>…………………………………………………. <route> <from uri="servlet:///my_url" /> <bean ref=“urlHandler” method=“handle" /> <transform> <constant>DONE</constant> </transform> </route>………………………………………………….</camelContext>
  12. 12. Basic example. JAVA DSL public class MyRouteBuilder extends RouteBuilder{ public void configure() { from(" servlet:///my_url "). process(new UrlHandler()).to("direct:b"); }};Orpublic class MyRouteBuilder extends RouteBuilder{ public void configure() { from(" servlet:///my_url "). processRef(“urlHandler”).to("direct:b"); }};
  13. 13. Processor@Component(“urlHandler”)public class UrlHandler{ public void handle(Exchange ex){ ex.getIn(); //handle input }}
  14. 14. More complex example<route> <from uri="activemq:queue:queueName" /> <unmarshal ref="xstream-utf8" /> <bean ref=“firstProcessor" method="process" /> <bean ref=“secondProcessor" method="process" />……………………………………………………………………………………. <bean ref=“lastProcessor" method="process" /> <to uri="direct:anotherRoute" /></route>
  15. 15. Components• Amazon stack• Apache stack(service miz, fop, cxf,)• DBs(jdbc, jpa, ibatis)• EJB• File(ftp, ftps, file, hdfs)• Google stack(gae, guice, gmail, gtask)• Hazelcast• JMS• JMX• Mail (IMAP, POP)• Queues• Twitter• Many others
  16. 16. Components exampleTo poll, every 5 sec., all statuses on your home timeline and send to gmail:Java DSLfrom("twitter://timeline/home?type=polling&delay=5&consumerKey=[s]&co nsumerSecret=[s]&accessToken=[s]&accessTokenSecret=[s]").to("gmail://a ccount1@gmail.com")XML DSL<route> <from uri="twitter://timeline/home?type=polling&delay=5&consumerKey=[s]&c onsumerSecret=[s]&accessToken=[s]&accessTokenSecret=[s]"/> <to uri=" gmail://account1@gmail.com "/></route>
  17. 17. Data Formats• Standard java serialization• Object marshalling (json, protobuf)• Object xml marshalling (xstream, jaxb, jixb, castor, xmlbeans• Object/XML/Webservice marshalling (SOAP)• Direct JSON / XML marshalling• Flat data structure marshalling (BeanIO, bindy, csv, edi, flatpack dataformat)• Domain specific marshalling (HL7)• Compression (gzip, zip)• Security (Crypto, PGP, XMLsecurity)• Misc (custom dataformat, rss, syslog, tidymarkup)• Dozer Type Conversion
  18. 18. Marshalling example<route> <from uri="direct:start"/> <marshal ref="myJaxb"/> <to uri="direct:marshalled"/></route><route> <from uri="direct:marshalled"/> <unmarshal ref="myJaxb"/> <to uri="mock:result"/></route>
  19. 19. EIP• Dynamic Router• Recipient List• Message Filter• Wire Tap• Throttler• Load Balancer• Multicast• Others
  20. 20. Summary
  21. 21. Questions?

×