Saturday, February 13, 2016

Apache Camel - How to use concurrency with WIPs? (8/250-2016)

Parallel Processing - 
EIPs in Camel that support concurrency - you can turn on parallel processing to use thread pool profiles to apply a matching thread pool (see pg 330 of Camel in Action)
  • Aggregate
  • Multicast -   (see pg 327 of   Camel in Action)
    • parallel processing of multiple routes - best used when multiple routes interacts with multiple systems
    • send copies of the msg to multiple routes
    • aggregate data after all execution complets
  • RecipientList
  • Splitter
  • Threads
  • WireTap
Custom Thread Pool - (see pg 320 of Camel in Action)

  • create thread pools using java.util.concurrent.Executors 
  • ExecutorService threadpool = Executors.newCachedThreadPool
    • the thread pool will grow and shrink - no upper bound - very aggressive
  • ExecutorService threadpool = Executors.newFixedThreadPool(20)


Staged Event Driven Architecture (SEDA) -  (see pg 322 of Camel in Action)

  •  breaks down complex application into statges using internal queues - to handover messages between routes.
  • eg:
from("file:\\...").to("seda:test")...from("seda:test?concurrentConsumers=20")

  • 20  

No comments: