1. Message Structure
- Message structure between Mule 3 and Mule 4
- Mule 4
Mule Event = Mule Message + Variables
Mule Message = Payload + Attributes
MULE 4 - Message Structure
-
Payload
It's the actual message content. Payload can be overridden.
Attributes
They provides meta data such as: queryParams, file size, etc.
They are immutable(can not be changed).
- Variables
They are something you can store some kind of data or information which can be used across the application as long as you connect the flows with flow-ref.
2. Anypoint Studio
It is the graphical IDE you develop mule application.
3. Mule Project Structure
- Every project in Mule 4 is a Mavenized Project
- All Mule xmls are placed under src/main/mule
- Other files can be placed under: src/main/resources or src/test/resources
- mule-artifact.json
- Each Mule app xml includes:
Message Flow(Graphical view)
Global Elements(contains all config details)
Configuration XML(xml version of graphical view)
4. Flow/Sub Flow/Private Flow
- An app can consist of a single flow
- Or it can break up processing into discrete(private) flows and sub flows that you add to the app and connect together
- Private and sub-flows can be triggered by Flow-reference or by DataWeave lookup
What is a Flow
-
A flow has "Source", "Process" and "Error Handling" parts
What is a Private Flow
- A private flow also has "Source", "Process" and "Error Handling" parts
-
But we don't keep anything in "Source" part of a private flow
What is a Sub Flow
- A sub flow does not have "Source" or "Error Handling" parts
- A sub flow has only "Process" art
- "Error Handling" for sub flows are handled by calling flow/private flow
5. Connectors
Anypoint Connectors are reusable extensions to Mule runtime engine (Mule) that enable you to integrate a Mule app with third-party APIs, databases, and standard integration protocols. Connectors abstract the technical details involved with connecting to a target system.
Using connectors in a Mule app provides the following advantages:
Reduces code complexity, because you can connect a Mule app to a target system without knowing all of the details required to program to the target system
Simplifies authenticating against the target system
Proactively infers metadata for the target system, which makes it easier to identify and transform data with DataWeave
-
Makes code maintenance easier because:
a. Not all changes in the target system require changes to the app.
b. The connector configuration can be updated without requiring updates to other parts of the app.
Some Commonly Used Connectors:
Http Listener
- Listens to the request which client/user sends
- Mandatory config details required: host, port, path
- Default: Accepts all kinds of methods if nothing is specified
Config Details Example:
Set Payload
- The Set Payload component lets you update the payload of the message
- The payload can be a literal string or a DataWeave expression
- Mandatory config details required: value
(eg: #["Hello World"] or #[payload] or #[attributes.queryParams.name])
Config Details Example:
6. Hands On
- 6-1) Create a simple project:
- 6-2) Drag a flow from Mule Palette into your canvas:
- 6-3) Drag a http listener from Mule Palette into Source part of your flow:
- 6-4) Add http listener config and test connection:
- 6-5) Fill in the path of the listener:
- 6-6) Drag a Set Payload from Mule Palette into Process part of your flow:
- 6-7) Set value of the Payload