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.

Integrating Microservices with Apache Camel


Published on

Slides from my Integrating microservices with Apache Camel and Fuse

Published in: Software
  • Be the first to comment

Integrating Microservices with Apache Camel

  1. 1. Integrating Microservices with Apache Camel and JBoss Fuse
  2. 2. 2 Who? Christian Posta Principal Middleware Specialist/Architect Blog: Twitter: @christianposta Email: • Committer on Apache Camel, ActiveMQ, Fabric8, PMC on ActiveMQ • Author: Essential Camel Components DZone Refcard • Frequent blogger and speaker about open-source technology!
  3. 3. Why do we care?
  4. 4. Where are we now?
  5. 5. • Domain modeling • Object Oriented design • Functional decomposiiton • Language specific modularity, decomposition, fault-tolerance (eg, Erlang) • Shared libraries? Decomposition techniques
  6. 6. • Agile methodology • Doman Driven Design • REST • Hexagonal Architectures • Pipes and Filters • Actor Model • SEDA Microservices emerged as a result…
  7. 7. A new term! Yay! A concept that helps describe distributed systems that organically evolve into scalable, loosely coupled, independently managed sets of services that work together to deliver business value with acceptable tradeoffs. So what are microservices?
  8. 8. Don’t get too caught up in the buzzword bingo; Microservices is a good concept, but it’s not itself a panacea. So what are Microservices?
  9. 9. • Flexible technology choices • “Smart endpoints” “dumb pipes” • Independently scalable • Decentralized, choreographed interactions • Testable • Automation, DevOps philosophy • Design for failure • Evolving design Microservice characteristics
  10. 10. • No silver bullet; distributed systems are *hard* • Dependency hell, custom shared libraries • Fragmented and inconsistent management • Team communication challenges • Health checking, monitoring, liveness • Over architecting, performance concerns, things spiraling out of control fast Challenges with Microservices!
  11. 11. Why Apache Camel?
  12. 12. Real developers ride Camels!
  13. 13. 1 Apache Camel Apache Camel is an open-source, light-weight, integration library. Use Camel to integrate disparate systems that speak different protocols and data formats
  14. 14. Apache Camel Enterprise Integration Patterns
  15. 15. Features ● Enterprise Integration Patterns (EIPs) ● Domain Specific Language to write “flows” or “routes” ● Large collection of adapters/components for legacy systems, B2B, and SaaS ● Strong Unit test/Integration test framework ● Expression languages ● Data Formats ● Tooling with JBoss Developer Studio
  16. 16. Pipes and Filters
  17. 17. Java DSL public class OrderProcessorRouteBuilder extends RouteBuilder { @Override public void configure() throws Exception { from(“activemq:orders”) .choice() .when(header(“customer-rating”).isEqualTo(“gold”)) .to(“ibmmq:topic:specialCustomer”) .otherwise() .to(“ftp://user@host/orders/regularCustomers”) .end() .log(“received new order ${body.orderId}”) .to(“ibatis:storeOrder?statementType=Insert”); } }
  18. 18. Spring XML DSL <route id=“processOrders”> <from uri=“activemq:orders”/> <choice> <when> <simple>${header.customer-rating} == ‘gold’</simple> <to uri=“wmq:topic:specialCustomer”> </when> <otherwise> <to uri=“ftp://user@host/orders/regularCustomers” /> </otherwise> </choice> <log message=“received new order ${body.orderId}”/> <to uri=“ibatis:storeOrder?statementType=Insert”/> </route>
  19. 19. Camel - JBoss Developer Studio
  20. 20. • Dynamic routing options • REST DSL • Backpressure mechanisms • Loadbalancing algorithms / Circuit Breaker pattern Heavy Lifting: Camel for Microservices
  21. 21. • “Smart endpoints, dumb pipes” • Endpoint does one thing well • Metadata used for further routing • Really “dynamic” with rules engine (eg, Drools/BRMS) Dynamic Routing
  22. 22. • Content Based Router • Dynamic Router • Routing Slip • Recipient List Dynamic Routing
  23. 23. • Expressive way to define REST endpoints • POST, REST, PUT • Auto binding to POJOs • Plugs into Swagger for interface definition/documentation • Uses configurable HTTP engine • camel-netty-http • camel-jetty • camel-reslet • camel-sevlet (deploy into other containers) • camel-spark-rest REST DSL (2.14)
  24. 24. REST DSL public class OrderProcessorRouteBuilder extends RouteBuilder { @Override public void configure() throws Exception { rest().post(“/order/socks”) .description(“New Order for pair of socks”) .consumes(“application/json”) .route() .to(“activemq:topic:newOrder”) .log(“received new order ${body.orderId}”) .to(“ibatis:storeOrder?statementType=Insert”); } }
  25. 25. • Backpressure is a way for a service to flow control callers • Detecting when can be difficult • Need to bound processing queues in a SEDA • Take advantage of built in TCP flow control for socket/http requests Backpressure with Camel
  26. 26. • Throttle EIP • • Blocking SEDA Queue • from(“seda:name?size=100&blockWhenFull=true) • Configure jetty/netty to use blocking acceptor queues • • Using Exception handling/retry and DLQ logic when getting flow controlled • Backpressure with Camel
  27. 27. • Useful to keep from overloading a system (use in conjunction with backpressure if you can) • Smart loadbalancing • Sticky • Random • Failover • Circuit breaker Loadbalance/Circuit breaker
  28. 28. Circuit breaker Image from
  29. 29. Circuit breaker public class OrderProcessorRouteBuilder extends RouteBuilder { @Override public void configure() throws Exception { from(“direct:someinterface”) .loadbalance() .circuitBreaker(3, 20000L, MyException.class) .to(“ibatis:storeOrder?statementType=Insert”); } }
  30. 30. Apache Camel More Information ● Camel in Action ● Apache Camel Developer’s Cookbook ● Community website ○
  31. 31. Why JBoss Fuse?
  32. 32. RED HAT JBOSS FUSE Development and tooling Develop, test, debug, refine, deploy JBoss Developer Studio Web services framework Web services standards, SOAP, XML/HTTP, RESTful HTTP Integration framework Transformation, mediation, enterprise integration patterns Management and monitoring System and web services metrics, automated discovery, container status, automatic updates JBoss Operations Network + JBoss Fabric Management Console (hawtio) Apache CXF Apache Camel Reliable Messaging JMS/STOMP/NMS/MQTT, publishing-subscribe/point-2-point, store and forward Apache ActiveMQ Container Life cycle management, resource management, dynamic deployment, security and provisioning Apache Karaf + Fuse Fabric RED HAT ENTERPRISE LINUX Windows, UNIX, and other Linux
  33. 33. Managing microservice deployments
  34. 34. • Simplifies deployments • Provides centralized configuration • Provides cluster capabilities, coordination • Service discovery • Smart load balancing • Failover • Versioning • Visualize your middleware with HawtIO
  35. 35. Demo and Questions