In this article, I want to show to you how you can skip or exclude flow from initialize and start while deploying mule 4 applications in local or in cloud. Also, I will show you how you can exclude files from packaging jars.
Problem:
In mulesoft development there are high chance of having large number of files for flows/ subflows and due to this it leads to:
Above scenarios are more painful when we need a quick fix and testing of code in local or in cloud environment.
Let's check scenario below, as we are able to see in project below we have three files under src/main/mule package. Each file is having individual flows as highlighted in picture below:
In mule4, we have "mule-artifact.json" file where we can declare files to be considered for initializing and starting of the flows under configs tag. By default, if we don't declare any file names, Mule runtime includes All files to check, initialize and starting of the flows.

Below logs shows only "HelloWorldFlow" is initialized and started for deployment.
So, if we don't declare any file to include for execution, below logs shows mule runtime started and initialized all flows from all files.
Although above configuration helps you to exclude flows to initiate and start while deploying application in local or in cloud. It helps to reduce total deployment time of mule apps. But with above configuration you will not be able to exclude files or folders from packaging jar.
To achieve this, we need to create "_muleExclude" file at the root level of mule application.

You can declare file names to exclude from packaging jar as shown above.
- Long build and deployment time.
- Bulk packaging.
Let's check scenario below, as we are able to see in project below we have three files under src/main/mule package. Each file is having individual flows as highlighted in picture below:
mule4-flows
In mule4, we have "mule-artifact.json" file where we can declare files to be considered for initializing and starting of the flows under configs tag. By default, if we don't declare any file names, Mule runtime includes All files to check, initialize and starting of the flows.

mule-artifact-json.png
Below logs shows only "HelloWorldFlow" is initialized and started for deployment.
![]() |
flow-logs |
So, if we don't declare any file to include for execution, below logs shows mule runtime started and initialized all flows from all files.
![]() |
flow-logs |
Although above configuration helps you to exclude flows to initiate and start while deploying application in local or in cloud. It helps to reduce total deployment time of mule apps. But with above configuration you will not be able to exclude files or folders from packaging jar.
How to exclude files or folders from packaging jars?
To achieve this, we need to create "_muleExclude" file at the root level of mule application.

_muleExclude-mule4.png
You can declare file names to exclude from packaging jar as shown above.
Above picture also shows extracted jars is not having files included inside "_muleExclude" file.
Note: Please make sure above configurations should be used wisely as it may lead to application failure.
If you want to know more about minMuleVersion you can check my article runtime-patching-in-mule-munit
Happy Learning :)
Note: Please make sure above configurations should be used wisely as it may lead to application failure.
If you want to know more about minMuleVersion you can check my article runtime-patching-in-mule-munit
Happy Learning :)
No comments:
Post a Comment