0% found this document useful (0 votes)
6 views5 pages

Module 2 Part 2

Module 2 covers structuring Mule applications by organizing flows and subflows, utilizing asynchronous queues for event passing, and managing application properties. It emphasizes the importance of separating concerns, encapsulating global elements, and organizing project files for better readability and maintenance. Additionally, it discusses the use of Maven for project management and the significance of metadata in defining application structure.

Uploaded by

nebranmichael26
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views5 pages

Module 2 Part 2

Module 2 covers structuring Mule applications by organizing flows and subflows, utilizing asynchronous queues for event passing, and managing application properties. It emphasizes the importance of separating concerns, encapsulating global elements, and organizing project files for better readability and maintenance. Additionally, it discusses the use of Maven for project management and the significance of metadata in defining application structure.

Uploaded by

nebranmichael26
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 5

In Module 2, I will discuss on how to structure your mule application.

---

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:

- Create applications composed of multiple flows and subflows


- Pass events between flows using asynchronous queues
- Encapsulate global elements in separate configuration files
- Specify application properties in a separate properties file and use them in the
application
- Describe the purpose of each file and folder in a Mule project
- Define and manage application metadata

------------------

Next topic is Encapsulating processors into separate flows and subflows

---

Break up flows into separate flows and subflows

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.

---

There are several methods to create flows and subflows

- 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.

- Use flow reference component to pass events to other flows or subflows

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

When a flow or subflows is renamed all references to it are automatically renamed


as well.

-------------------------------------------
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

but if you want to pass events asynchronously 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.

- Distribute work across a cluster


- Communicate with other applications that running in the same mule domain
- Queueing can also be implemented using JMS Broker which will be covered in module
7

---

Using the VM Connector

- 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

-------------------------------------------

Next is Organizing Mule application files

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.

---

Encapsulating global elements in a configuration file

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

we can also separate your functionality to multiple applications that allows us to


manage and monitor them separately and access functionality from JAR files that
could be incompatible if used in a single application.

Run more than one application at a time in Anypoint Studio by creating a run
configuration.

---

Sharing global elements between applications

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

-------------------------------

Next is Organizing and parameterizing application properties

---

Application properties

Mule application can be configured property placeholder to replace static values


with value that stored in YAML or a properties files .

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.

---

To use application properties,

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.

---

There are two formats for property placeholders

First is global element configurations and event processors using the format $
{db.port} to enclose an object property name.

Second is In DataWeave expressions using the format {port: Mule::p('db.port')} to


reference 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.

-------------------------------------------

Next is Organizing mule project files

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.

----

Ways to access the 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.

----

Where is metadata stored?


In the application types XML file is created in the src/main/resources folder. this
is done when the first metadata definition is created.

-------------------------

In summary,..

read the PDF

You might also like