Sunday, November 8, 2015

In-Memory Components

Camel provides in-memory components like  Direct, Direct VM,SEDA and VM .These components route  messages without using external broker.They should be used when performance or speed takes precedence over reliability requirements.

Direct/Direct VM :
The Direct component allows to make direct synchronous call between a producer and a consumer. This is the simplest component as it requires no additional configuration. It is mainly used to link routes within a Camel Context  and  to expose a route as a synchronous service.
Direct VM is similar to Direct ,only difference is that it supports communication across multiple Camel Context instances within the same JVM.

SEDA :
The SEDA component  is used for asynchronous messaging and is considered as low overhead replacement for JMS .SEDA allows messaging  within a single  Camel Context. It supports concurrent users  in which the configured end points will be triggered and run in separate thread.

VM is similar to SEDA except that it supports communication across multiple Camel Context instances within the same JVM.



Component   Pros Cons
Direct/Direct VM
  • Simple to use
  • Allows to reuse route
  • Minimal Overhead

  • Used only when Producer and Consumer are up at the same time, this may not be viable for all use cases.
  • Works on Single thread only
SEDA /VM
  • Faster than JMS as it is in memory
  • Supports concurrent users

  • Message Persistence not supported so there is a risk of losing message if event of   crash.
  • Transactions are not supported as each call is invoked  on a different thread.