flows and subflows in mule

17
FLOWS AND SUBFLOWS IN MULE Presented By Sindhu VL

Upload: sindhu-vl

Post on 08-Jan-2017

199 views

Category:

Design


3 download

TRANSCRIPT

Page 1: Flows and subflows in mule

FLOWS AND SUBFLOWS IN MULE

Presented BySindhu VL

Page 2: Flows and subflows in mule

Mule applications are built around one or more flows.

Typically, a Mule application begins processing a message it is received by an inbound endpoint in a flow.

This flow can then either implement all processing stages, or route the message to other flows or subflows to perform specific tasks.

Relative to the flow which triggered its execution, a flows and subflows can process messages either synchronously or asynchronously.

Page 3: Flows and subflows in mule

Synchrounous flow :

Page 4: Flows and subflows in mule

Asynchrounous flow :

Page 5: Flows and subflows in mule

Advantages of Using Multiple Flows in an Application :

Asynchronous Flow B can perform time-consuming tasks, such as writing data to an external database or emailing a message, without stalling Flow A, the flow that triggered its execution.

Flow A and Flow B can respond differently to errors.

Breaking up complex operations into a series of smaller flows or subflows makes applications – whether in a GUI or in XML code – easier to read.

Page 6: Flows and subflows in mule

The processing actions in a flows or subflows can be called and used by multiple flows in an application. 

In clusters of Mule servers, messages can migrate between nodes when sent to an asynchronous flow. This allows for load balancing between nodes and higher performance of application. (See our advanced use case for an example.)

Page 7: Flows and subflows in mule

Types of Flows : When its execution is triggered by

another flow in an application, a flow exists as one of three types:

1. Subflow2. Synchronous Flow3. Asynchronous Flow

Page 8: Flows and subflows in mule

Subflow : A subflow processes messages

synchronously (relative to the flow that triggered its execution) and always inherits both the processing strategy and exception strategy employed by the triggering flow. While a subflow is running, processing on the triggering flow pauses, then resumes only after the subflow completes its processing and hands the message back to the triggering flow. 

Page 9: Flows and subflows in mule

Synchronous Flow : A synchronous flow, like a subflow, processes

messages synchronously(relative to the flow that triggered its execution). While a synchronous flow is running, processing on the triggering flow pauses, then resumes only after the synchronous flow completes its processing and hands the message back to the triggering flow. However, unlike a subflow, this type of flow does notinherit processing or exception strategies from the triggering flow.

This type of flow processes messages along a single thread, which is ideally suited to transactional processing. 

Page 10: Flows and subflows in mule

Asynchronous Flow : An asynchronous flow simultaneously

and asynchronously processes messages in parallel to the flow that triggered its execution. When a flow passes a message to an asynchronous flow, thus triggering its execution, it simultaneously passes a copy of the message to the next message processor in its own flow. Thus, the two flows – triggering and triggered – execute simultaneously and independently, each finishing on its own. This type of flowdoes not inherit processing or exception strategies from the triggering flow.

This type of flow processes messages along multiple threads.

Page 11: Flows and subflows in mule

Advantages of Subflows : A subflow can isolate logical processing blocks,

making the graphical view more intuitive and the underlying XML code much easier to read.

Subflows are ideally suited for code reuse, so you can write a particular block of code once, then reference the same subflow repeatedly from within the same application. The diagram below offers an example of a subflow that is executed twice by different flow reference components in the same flow.

Subflows inherit the processing strategies and exception strategies of the flow that triggers it, which means you don’t have to define these same configuration details again when building a subflow.

Page 12: Flows and subflows in mule

Example subflow :

Page 13: Flows and subflows in mule

Advantages of Synchronous flows :

Like a subflow, a synchronous flow processes messages synchronously relative to the flow that triggered it. Unlike a subflow, a synchronous flow does not inherit the triggering flow’s processing or exception strategies. Thus, you can set the synchronous flow’s processing and  exception strategies to behave differently from the exception strategy you configured for the flow(s) which triggered its execution.

Moreover, because it does not inherit a triggering flow’s parameters, a synchronous flow can accept calls from multiple flows within an application (see image below) using its own processing and exception strategies.  In other words, a flow:synchronous flowrelationship is n:1.  (Of course, a flow can call multiple synchronous flows, so the relationship could really be described as n:n.)

Page 14: Flows and subflows in mule

Example Synchronous flow :

Page 15: Flows and subflows in mule

Advantages of Asynchronous Flows :

Asynchronous flows begin processing a message when triggered by another flow. Since this type of flow does not need to return data to the flow which triggered it, it can execute simultaneously to its triggering flow. In other words, when Flow A triggers asynchronous Flow B, it neither passes programmatic control to the asynchronous flow, nor does it pause its own message processing. In the image below, the asynchronous flow uses its own exception strategy and can be called multiple times within a single flow or many times by multiple flows to inject data into an external database.

Page 16: Flows and subflows in mule

Example Asynchronous flow :

Page 17: Flows and subflows in mule

ThankYou!!!!!!!!