Difference between Flow, Sub Flow and Private Flow in Mule3
    In Mule 3 we have three types of flow present:
    • Flow
    • Sub Flow
    • Private Flow
    Find a example of each flow in STUDIO Visual Editor :

    Find a example of each flow in XML Editor :

    All three Flow types can be referenced from a Flow Reference component.
  • Flow
    • Flow is a message processing block that has its own processing strategy and exception handling strategy.
    • Flow can Use in integration tasks, data processing, connecting applications, event processing etc.
  • Sub flow
    • Subflow always processes messages synchronously but inherits processing strategy and exception handling strategy from the calling flow.
    • Subflow can be used to split common logic and be reused by other flows.
  • Private flow
    • Processing strategy :
      • Sub-flow: It is always synchronous
      • Private-flow: Its behaviour depends on the processing strategy

    • Performance :
      • Sub-flow: It has a better performance when using request-response exchange pattern as they are actually a new processor chain injected in the flow at configuration time.
      • Private-flow: It is useful for asynchronous call, if we configured the processing strategy properly

    • Exception strategy :
      • Sub-flow: will use the exception strategy defined in the main flow and it will have the exception got in the sub-flow.
      • Private-flow: the exception will be trapped by the local exception strategy. The exception will not be propagated to that main flow.

    • Message Properties :
      • In both case all properties, regardless their scope, are preserved from the main flow.

    • Threading profile :
      • Sub-flow: will share the parent flow threading profile configuration
      • Private-flow: allows you to define a different threading profile, but if you don't they will use the default one, not inherit the invoking flow one.

    • Overall :
      • Sub-flow: Sub flow run within the same execution context (exception handler, transaction, properties) of its main flow.
      • Private-flow: Private flow will initiate a new execution context.

    • To summarize :
      • Sub flow is always recommended except in the case the exception needs to be handled in a separate flow different from the main flow or you are implementing an asynchronous pattern.

If you got some knowledge about Difference between flow, sub flow and private flow, please follow with me in next topic to understand about Flow Processing Strategies.

Comments