Saturday, February 13, 2016

Apache Camel - Synchronicity & Threading (9/250-2016)

A service can be called synchronously as well as asynchronously
After the service is invoked - the consumer can use multiple / single thread to complete the operation.

The factors which affect the threading model 

  • Component - which starts the process - whether it is fire and forget or request/reply messaging style
  • EIP - some support parallel processing (concurrency)
  • Configured Synchronicity - some components can be configure to be sync/async
  • Transactions - if a route is transacted -- the transactional context is limited to run within one thread only.
  • MEP (Message Exchange Pattern) - information in the exchange telling InOnly / OutOnly / InOut
Different scenarios discussed in the book - 
  • Async caller - Camel uses only one thread 
    • template.sendBody = InOnly Msg
    • caller sending InOnly Msg
    • single thread - pros
      • simple
      • support transaction propagation
    • cons
      • consumer threads can be overloaded by number of incoming messages
  • Sync Called - Camel uses multi thread
    • template.requestBody = InOutBody
  • Async caller - Camel uses only one thread
  • Sync caller - Camel uses multi thread

References: 

No comments: