Skip to content

W-11599400-flowRevamp-duke #2411

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: v4.4
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion modules/ROOT/nav.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* xref:whats-new-in-mule.adoc[What's New in Mule]
* xref:index.adoc[Mule Overview]
** xref:mule-components.adoc[Mule Components]
** xref:about-flows.adoc[Flows and Subflows]
** xref:about-mule-configuration.adoc[Mule Configuration File]
** xref:about-mule-event.adoc[Mule Events]
*** xref:about-mule-variables.adoc[Variables in Mule Events]
Expand Down
3 changes: 2 additions & 1 deletion modules/ROOT/pages/_partials/nav-app-dev.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
*** xref:business-events-custom.adoc[Custom Business Event Component]
*** xref:dynamic-evaluate-component-reference.adoc[Dynamic Evaluate Component]
*** xref:first-successful.adoc[First Successful Router]
*** xref:flow-component.adoc[Flow and Subflow Scopes]
*** xref:about-flows.adoc[Flow and Subflow Scopes]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consolidate these

**** xref:flow-component.adoc[Flow and Subflow Scopes]
*** xref:flowref-about.adoc[Flow Reference Component]
*** xref:for-each-scope-concept.adoc[For Each Scope]
*** xref:idempotent-message-validator.adoc[Idempotent Message Validator]
Expand Down
57 changes: 29 additions & 28 deletions modules/ROOT/pages/flow-component.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,51 +6,52 @@ endif::[]
:toc:
:toc-title:

toc::[]

//Anypoint Studio, Design Center connector
[[short_description]]
Flow and Subflow scopes are components for grouping together a sequence of other
Core components and operations (provided by connectors and modules) to help
automate integration processes. The Flow component is fundamental to a
Mule app. Because all Mule apps must contain at least one flow, Anypoint
Studio and Flow Designer automatically provide the first Flow component in
your Mule app.

A Mule app can contain additional flows and subflows, as this example shows:
Flow and Subflow scopes are components for grouping together and executing a sequence Mule components and connector operations within a Mule application. The All Mule applications must contain at least one Flow component. Additional flows and subflows are optional.

.Example: Flow with Subflows
image::component-flow-subflow.png[Example of Flow with Subflows]

Flows and subflows process Mule events synchronously. To achieve
asynchronous patterns, such as Fire-and-Forget, you can add the
xref:async-scope-reference.adoc[Async scope] (`<async/>`) within a Flow a
Subflow scope.

For a more in-depth discussion of uses, capabilities, and limits of flows and
subflows, see xref:about-flows.adoc[Flows and Subflows].

Note that flows always function synchronously. If you need to achieve
asynchronous patterns, such as Fire-and-Forget, you can use the
xref:async-scope-reference.adoc[Async Scope] (`<async/>`).

== Flow Configuration
== Reference

Flows are configurable. For example, you can set them to start or remained
stopped when the Mule app starts, place limits on the allowed concurrency, or set
up business events. You can also set up error handling for a component
(see <<error_handling>>).
stopped when the Mule application starts, place limits on the allowed concurrency, or set up business events. You can also set up error handling for a component (see <<error_handling>>).

//TODO: NEED BETTER BUSINESS EVENTS DOCS (SEE DOCS-2146).
[%header,cols="1,4"]
The XML for a flow that sets values for all available attributes looks like this:

[source,xml]
----
<flow name="flow_component_ex" tracking:enable-default-events="true"
initialState="started" maxConcurrency="1">

// Processors here

</flow>
----

[%header,cols="1a,1a,4a"]
|===
| Field | Description
| Name (`name`) | Name for the flow. Flows automatically receive an editable name that matches (or partially matches) the project name.
| Initial State (`initialState`) a| Values: Started, Stopped. These are Mule runtime settings for the flow. The default, Started (`initialState="started"`, also called Empty in Studio), indicates that the flow is active when you start the app. So it can be triggered by an internal or external event source within the flow (such as an HTTP listener or Scheduler), by a Flow Reference from another flow or subflow, or through a call to the xref:dataweave::dataweave-runtime-functions.adoc#functions_runtime[lookup] function.
| Field Name | XML | Description
| Name | `name` | Name for the flow. Flows automatically receive an editable name that matches (or partially matches) the project name.
| Initial State | `initialState` | Accepts the following Mule runtime settings for the flow: `started` (default) or `stopped`. The setting `initialState="started"` indicates that the flow can be triggered by an internal or external event source within the flow (such as an HTTP listener or Scheduler), by a Flow Reference from another flow or subflow, or through a call to the xref:dataweave::dataweave-runtime-functions.adoc#functions_runtime[lookup] function.

If you set the initial state to Stopped (`initialState="stopped"`), you need to use xref:runtime-manager::flow-management.adoc[Runtime Manager] to activate the flow, or you can simply reset the Flow configuration to `Started`. Note that the console
output for this state looks something like this: `Flow flow_component_ex has not been started (initial state = 'stopped')`
If you set the initial state to `stopped`, you can use xref:runtime-manager::flow-management.adoc[Runtime Manager] to activate the flow in an application that is deployed to CloudHub, or you can reset the Flow configuration to `started` from Studio when developing the application. The Studio console for the `stopped` state prints a message like this one: `Flow flow_component_ex has not been started (initial state = 'stopped')`
| Max Concurrency (`maxConcurrency`) a| Optional. Sets the maximum number of concurrent messages that a flow can process. If not set, the container thread pool determines the maximum number of threads the flow can use to optimize the performance when processing messages. While the flow is processing the maximum number of concurrent messages, it cannot receive additional requests.

Set `maxConcurrency` to `1` to cause the flow to process requests one at a time.

See xref:execution-engine.adoc#backpressure[Back-pressure] for details about Mule's behavior after the the maximum concurrency value is reached.
| Business Events a| Optional: Defaults to `false`. For Mule apps that you deploy to CloudHub, you can enable business events (XML example: `tracking:enable-default-event="true"`) and add a Transaction ID (XML example: `<tracking:transaction id=12345`/>). See xref::business-events.adoc[Business Events].
| Business Events a| Optional: Defaults to `false`. For Mule applications that you deploy to CloudHub, you can enable business events (XML example: `tracking:enable-default-event="true"`) and add a Transaction ID (XML example: `<tracking:transaction id=12345`/>). See xref::business-events.adoc[Business Events].
| Metadata | As with many other components, you can set metadata for this component. For more on this topic, see the Studio document xref:7.1@studio::metadata-editor-concept.adoc[Metadata Editor].
|===

Expand All @@ -65,12 +66,12 @@ Subflow scopes provide a way to edit the name of the subflow and to add metadata
| Metadata | As with many other components, you can set up metadata for this component. For more on this topic, see the Studio document xref:7.1@studio::metadata-editor-concept.adoc[Metadata Editor].
|===

== XML for Flows and Subflows
== Example

This example shows the XML for a simple flow (`<flow/>`) that uses a Scheduler as a source to trigger execution of
This example shows the XML for a flow (`<flow/>`) that uses a Scheduler as a source to trigger execution of
the flow every 10 seconds, and it connects to a subflow (`<sub-flow/>`) through a Flow Ref (`<flow-ref/>`) component. That
subflow then connects to another subflow, also using a Flow Ref component. Note
that when you configure components through the Studio UI, Studio automatically adds the XML to the Configuration XML for your Mule app.
that when you configure components through the Studio UI, Studio automatically adds the XML to the Configuration XML for your Mule application.

.Example: XML for a Flow and Subflows
[source,xml,linenums]
Expand Down