Anatomy of a Mule Flow
A Mule flow is the fundamental processing unit — a chain of message processors triggered by a source.
Every flow starts with a source (also called a trigger or listener): an HTTP Listener, a Scheduler, a JMS Consumer, etc. When the source fires, it creates a Mule Event containing a payload, attributes, and a set of variables.
The event passes through a sequence of processors: transformers, routers (Choice, Scatter-Gather), scopes (Try, Async), and operation components (connectors). Each processor can read and modify the event.
Sub-flows are re-usable flow fragments with no source. They are invoked with the Flow Reference component and execute synchronously in the same thread as the caller.
<flow name="get-orders-flow">
<http:listener config-ref="HTTP_Listener_config"
path="/api/v1/orders"
allowedMethods="GET" />
<logger level="INFO"
message="Received GET /orders from #[attributes.remoteAddress]" />
<db:select config-ref="Database_Config">
<db:sql>SELECT * FROM orders WHERE status = :status</db:sql>
<db:input-parameters>#[{ status: attributes.queryParams.status default 'active' }]</db:input-parameters>
</db:select>
<ee:transform>
<ee:message>
<ee:set-payload><![CDATA[%dw 2.0
output application/json
---
payload map (row) -> {
orderId: row.ORDER_ID,
customer: row.CUSTOMER_NAME,
amount: row.TOTAL_AMOUNT
}]]></ee:set-payload>
</ee:message>
</ee:transform>
</flow>