Mulesoft Notes 1670516676
Mulesoft Notes 1670516676
Business data
connector
Acquired by Salesfore
(Communicates
on May’2018
between 2 or more
systems)
What is Mulesoft
Founded in 2006 by
Mule = Donkey + Horse
Ross Mason
Competitors : DELL
EAI Product
BOOMI, TIBCO etc…
What is
Integration
• Integration is the act of
bringing together smaller
components into a single
system that functions as one
• Integration is the process of
connecting multiple
enterprise systems, devices,
or applications to work as a
whole
• Milk + Water + Sugar+Tea
powder = Tea
• An API is a set of programming code that enables data
transmission between one software product and another. It
also contains the terms of this data exchange.
• Reusable piece of code
What is an API • Divided into 3 Layers
• System API
• Process API
• Experience API
What is an API specification
Policies • IP blocklist
• IP whitelist
• Jwt validation
• Basic Auth
Most Used Policy : Cliend ID Enforcement
Applying client enforcement policy
Unregistered to Registered status via
cloudhub deployment
Runtime Manager: Deploy to cloudhub via Studio
AccessManagent: Get ClientID & ClientSecret
Pasting ClientID & ClientSecret in Runtime Properties
• Basic Auth -> Asks Username & Password
• ClientID Enforcement -> Requires client_id &
client_secret
Policies • Rate Limiting -> Send the set amount of
request for particular time period
&Uses • IP Whitelist : Having Access to the Ip’s which
are in the list
• IP Blacklist: Does not have access to the IP’s
mentions in the list
Additional about RAML & Status codes:
Package explorer
Canvas Palette
Console
Important points
about Mule
• Mulesoft is a Mavenized project
• All Mule xml’s 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 has – Message
flow(graphical view), Global elements(all
config details), Configuration xml (xml
version or graphical view)
Flow is a message processing block that has its own
processing strategy and exception handling strategy.
Used in integration tasks, data processing, connecting
applications, event processing, etc.
Private flow Private flow does not have source define. It can be
synchronous or asynchronous based on the processing
strategy selected. Also they have their own exception
handling strategy. Allows you to define different
threading profile.
Flow Sub Flow Private Flow
Flow have Source, Process and A flow that do not have Source and A flow that have Source, Process &
Error handling part Error handling Error handling
We will give reference to other Having only Process part We will call it as private flow when
flows based on requirement source part is empty
Private-Flow
Sub-Flow
Flow
Automated vs Manual Project
Xml
Java
By ID By name
orderBy is used to keep the array in
orderBy in DataWeave Order (Ascending/Descending)
Id Name
distinctBy : To remove duplicate records (Unique date)
If the id/location/name is empty
default : Not to store Null values then a default placeholder will be
set in that place
If-else in DataWeave
• If-else is a conditional
statement
• Syntax:
Eg: Status: if($.marks >= 60)
“Pass” else “Fail”
Task:- Learn about
• Link to Learn Functions/Methods:
DataWeave Functions • https://www.w3schools.com/java/java_methods.asp
and come back
TypeCasting
Get Time with
now(),now() as Date
& Required format
Now() “YYYY-MM-
DDTHH:SS:MS.SSSZ”
now() as “YYYY:MM:DD”
Date
Now() as “DD-MM-YY”
Date as
String{form
at:’dd-MM-
YY’}
Date Country Wide
• To call any “private flow” or Subflow we are using
Flow reference
• We can also call private flow component with
DataWeave function called Lookup
DataWeave • We cannot call Subflow with with DataWeave
function “Lookup”
Lookup • Syntax: Mule::lookup(“private-flow-name”,
“Payload can be passed here”)
• Link:
https://docs.mulesoft.com/dataweave/2.2/dw-
mule-functions-lookup
Scatter-Gather
• Scatter Gather sends the request message to
multiple targets concurrently, It collects responses
from various targets and aggregate them to a single
message
• Output payload is the combination all targets. And
each target output has (Payload+attribute)
• So its best practice to wrap every target within Try-
Block with On-Error-Continue, So you can handle
the errors and complete the process successfully
• The total time taken to process all targets is the
time took by single process (i.e Max 20secs)
• Use Try, On error continue to avoid errors. Because
if you get error even in one process, all processes
will be stopped
Scatter
Gather:
Example
Choice
Reutter
• The Choice router
dynamically routes messages
through a flow according to
a set of DataWeave
expressions that evaluate
message content
• Choice-reutter is like if-else
condition. It checks the
positive and negative
conditions and respond
accordingly
Connectors
Important Thing to remember while working
with connectors
File,SFTP, Database, Salesforce, any External web service etc… are some connectors
Gather the configuration details that are required while working with specific connector
See what is the request that particular system is accepting (Query param, Uri path, etc,.)
Check what amount of time taking to get the response for particular request
Connector:
Request
• In http request, We are giving control
to another system (External) or API
and requesting them to give control
over that system
• Http Request is used to call other
Web-services
• Response is received from External
system
• It is placed in “Process” area of
private flow (or) Subflow
• We need to make sure on sending
proper inputs to http Request
components like URL, method, the
input payload and attributes like
query and uri param what ever web-
service is expecting
Request :
Mandatory
Config details
• Mandatory config details
• Protocol (Http/https)
• Method (Get/Post/Delete/Put)
• URL or Path : If you provide whole
URL, Then port base path are not
required. If you give path, then
host, port, path are necessary
• You can pass Body, headers, attributes,
queryParams in respective tabs
• In the case of Error coming from Web-
service, we are calling to be considered
as success, then have make changes in
response tab of Http Request and make
use of Success-status-code-validator
Some External
API’s we can use
• Weather API:
• https://openweathermap.or
g/api#current
• Employees Data:
• https://dummy.restapiexam
ple.com/api/v1/employees
• Configuring External API
Response of SetRequest is same as Rest API
Connector : Validation
VM Connector
• Virtual Machine (VM Connector) manages intra-app and inter-app communication through either transient or persistent asynchronous queues
• Transient Queues: Faster than persistent queues, But they are not reliable if system crashes
• Persistent Queues : Slower but reliable
• What is Transient Queue?
• Transient Queues is used to make process Faster to store data in the memory, But they are not reliable if system crashes
• Transient Queue is faster than persistent Queue
• What is Persistent Queue?
• Persistent Queues are slower while compared with the transient queues to store data in the memory, But they are reliable
• Persistent Queue is Slower than Transient Queue
• When we will use VM connector
• If we want to pass the messages to another flow through queue mechanism instead of Flow-ref, We will go with VM Connector
• Used Communicate between different apps with in Mule system
• When we want to distribute work across the system
• Publish : Used to publish the message to
VM connector: queue and receive message from queue
Publish, • Consume: Used to retrieve/Subscribe the
data from Publish after the end of the
Consume, main flow
• Publish Consume: Used in place of Publish
Listener, to retrieve/Subscribe the data from
Publish subscriber flow
• Note: Using Post method
consume
VM Config
Connector : Database
• Mandatory config details required
• Driver
• Host
• Port
• User
• Password
• Database/service name/ instance
• SQL Query text
Notes to Remember about Database
Create
Some
Create Directory: Creating folder
in FTP/SFTP Move Move: It is like cut and paste(Move from one folder to another)
Config
Frequency setter
Auto Delete
• Run the flow
• Place a demo file in Input
Output • After Time Frequency it will move to the output folder & file
will be deleted from input folder
Difference between File/FTP/SFTP
File FTP SFTP
• What is an error?
• An error occurs when an unexpected event
happens while processing
• What Is Error handling?
• Exception handling is nothing but handling the
errors while unexpected event happens while
processing
• Levels of error handling:
• Flow level error handling
• Connector level error handling
• Custom error handling
• Global error handling
At what levels we can do Error handling ?
Capture error and stop the execution of the flow Captures the error and continues to the next level for
and returns the error code with 500.. Status code execution, It always returns 200 status code
Raise Error:
First Until
Try Cache
successful successful
Custom Deployment
Cloudhub vs Polling
connector / Domain project Load balancing models in
onpremises frequency
Custom policies mulesoft