Module 2 Part 2
Module 2 Part 2
---
Mule configuration files are the primary source for mule projects. Since we can
break your project into multiple files and flows we have the option to call those
flows so that we can easily understand your project.
---
In this module, we will learn how to:
------------------
---
Breaking your application down into smaller makes it more visually and the
underlying XML are more readable, it is also allows you to recognize patterns so
that they can be extracted into reusable and allows you to the separation of
concerns between an interface and implementation.
---
Flows vs Subflows
- Flows can have their own error handling strategy unlike the subflows can't
- Flows without event sources are sometimes called private flows because they can
only be accessed from within the application.
- A subflow has only the processor section and it is typically used to create
repeatable group of processor that run if it is contained in the calling flow.
- Flows is a scope that includes sections for a source processors and error
handling, source and error handling are optional.
---
- You can create flows and subflows manually by dragging onto the canvas and adding
processors
- Select a group of processors then right click and extract them into a new scope.
If you're trying to use the manual process, you can call from one scope to another
scope by adding flow reference, unless if you extract to a scope the processor will
automatically be replaced with a flow reference. Extracting processor will also
provide you with an opportunity to control the metadate between scopes and
extraction time.
- Variables persist through all flows unless the event crosses a transport boundary
-------------------------------------------
Next is Passing events between flows using asynchronous queues
The flow reference component is used for passing events between flows for
synchronous processing, and now I will discuss how to pass events between flows
using asynchronous queues.
---
When using flow reference, events are passed synchronously between flows
- The VM Connector can be used to make asynchronous calls between flows using VM
queues gives you the ability to increase the level of parallelism that allows you
to more-specific tuning of areas within a flow's architecture.
---
- In using VM Connector you need to add the VM Module to your project then create
global connector configuration to specify the queue name and wether it will be
transient or persistent. Transient queues are faster but are lost in the case of a
system crash and Persistent queues are slower but reliable
-------------------------------------------
Since API Kit automatically creates a new mule configuration file, we also want to
separate apps into multiple configuration and this helps to apply the separation of
concerns between the interface and implementation. Since Monolithic files are
difficult to read and maintain, You can add more additional files to make your
project easier to read, work with, to test and maintain.
---
global elements in one file that are defined in various, unrelated files it can be
confusing and hard to find, the good solution here is to create a configuration
file that can be used to encapsulate all your global reusable elements and it helps
to reduce the confusion on where to look the files and it allows other files to use
it as reference.
---
Creating multiple applications
Run more than one application at a time in Anypoint Studio by creating a run
configuration.
---
We can also create a domain project which is used to share global configuration
elements between applications, for example by using shared global elements it
allows us to use the same port to all of your application because it has the same
reference http listener configuration.
It is also important to note that domain projects can only be deployed to customer-
hosted mule runtime not on Cloudhub or RTF
-------------------------------
---
Application properties
The placeholder can be used with connector properties, credentials and other
configurations. The properties can be encrypted and overridden by the system
properties when deploying to different environments.
---
create a file such as a config dot YAML file in the resource folder then add
properties to the YAML file accordingly and create a configuration properties
global element that points to the file like in a YAML format.
This format uses tabs to create object with properties that are defined as key
value pairs with values formatted as strings.
---
First is global element configurations and event processors using the format $
{db.port} to enclose an object property name.
---
Overriding property values in different environments
- Property placeholder can be overriden by system properties, they can also be set
using JVM parameters either by using Anypoint Studio > Run Configuration >
Arguments or If you use standalone mule instances, you can use the command lines
parameters that shown in the screen.
-------------------------------------------
By organizing your mule project files you should understand the folder structure of
it and in naming of your folder should be indicate what they should contain it is
more easier to identify the folder just by looking to it.
SRC/test folders should contain only files needed at the time of development, while
the SRC main folders will be copied in to the JAR File that gets deployed to the
server.
---
Maven is a project management utility used by Anypoint Studio, when you create a
new mule project it can configure the correct folder structure.
Maven manages a project's build, reporting and documentation from a center piece of
information which is the project object model or POM
Maven produces one or more artifacts, like a compiled JAR and each artifact has a
group ID, artifact ID and a version string.
---
The POM is an XML file that defines settings for a Maven project that includes all
necessary settings to build a mule application like project dependencies and plug
in configurations
----------------------------------------
Managing metadata for a project
What is metadata? It is often beneficial to defind metadate depends where you may
want to use to define metadata.
In data sense can proactively identify metadata from internal and external source
however not all sources are data sense enabled so you have to manually provide your
own metadata by using metadata editor.
----
The metadata editor can be invoked by selecting set metadata in input panel or
define metadata from the output panel of the transform message component by
clicking the add metadata button in the metadata tab in processor properties or it
can be located in mule menu and select manage metadata types.
----
-------------------------
In summary,..