Hello
Everyone,
This post
will have a glance on what is Processing Strategy ? How we Choose it or how
Mule Application selects by default etc.
This concept
will help us to develop applications in a reliable way .
Processing
Strategy determines
how Mule implements Message processing for a given flow(s).
It
determines by:
Ø Should message be processed synchronously or
asynchronously? (Explained earlier)
Ø Should message be Non-Blocking strategy?
Ø If asynchronously , what are properties of pool of
threads used to process messages.
Ø If asynchronously , how messages wait for their turn
to be processed in 2nd thread.
All Mule Flows have a Default or implicit Startegy which mule
applies automatically.
Implicit
Processing Strategy :
Even though we do not define Processing
Strategy for flow created, it will be automatically applied by Mule. It can be
:
a)
Synchronous flow Processing
Strategy
b)
Queued
Asynchronous flow Processing Strategy.
How does it
selects???
It can be
selected based on 2 criteria’s :
1)
Flow’s Exchange
pattern :
There are two types of exchange patterns and based on it , the strategy
is defined.
a) Request-response exchange pattern: It is used when sender, I.e,
inbound endpoint expects response or some result to return to caller.
b) One-way Response exchange pattern: It is used when no-response is
expected or when result is sent to some other flow.
If its request response processing strategy, then its Synchronous
Processing Strategy.
2)
Whether or not
flow is transactional :
If flow is transactional, then it is
Synchronous Processing Strategy
|
Exchange Pattern
|
Transactional
|
Processing Strategy
|
|
Request-Response
|
Yes
|
Synchronous
|
|
Request-Response
|
No
|
Synchronous
|
|
One-way
|
Yes
|
Synchronous(because Transaction is Yes)
|
|
One-way
|
No
|
Queued Asynchronous
|
Note:
Request-response ----- Blindly Synchronous
Transaction
if Yes-----Blindly Synchronous
Some
Options:
a)
Change to
Synchronous : If
mule selects Queued Asynchronous Processing Strategy , we can specify a
Synchronous flow to achieve reliability.
b)
Fine Tune:
We can accept Mule’s
choice of Queued Asynchronous Processing Strategy , but fine-tune it .
Remember, we cannot fine tune Synchronous Flow.
c)
Wrap a
Flow: Inside async
Scope, we can wrap one or more message processors to achieve Asynchronous Processing
Strategy.
d)
Sub-flow: It’s a Synchronous Processing
Strategy
e)
Non-Blocking
Strategy: Available in 3.7+ version . To avoid having threads blocked while waiting for
Http-responses, which also requires less tuning. (Note: Not all
components are supported. Non supported components fall back to Synchronous Processing
Strategy).
f)
Custom: We can create custom Processing
Strategy by specifying in xml as :
<flow name=”xxx” processing strategy =” Processing Strategy name” >
|
Strategy
|
Description
|
|
Non-blocking
|
Applies using Http listener
|
|
Thread-per processor
|
Here every processor runs sequentially
in different thread
|
|
Asynchronous
|
Not applicable in most cases
|
|
Queued -thread
|
Not applicable in most Cases
|
No comments:
Post a Comment