Bonjour!
Base2Pro is a tutorial for Integration(MuleSoft), Salesforce, DotNet and DevOps related concepts.
December 16, 2020

RAML 1.0 Multiple Types for a Single Request
December 12, 2020

Mulesoft Interview Questions With Answers - Part 1
Bonjour!
What is Mulesoft?
The first and the most basic question asked in Mulesoft developer interviews.
Mulesoft is the vendor that provides an integration platform to help businesses connect data, applications, and devices.
Mule is the runtime engine of the Anypoint Platform. It is a lightweight Java-based enterprise service bus (ESB) that allows developers to connect applications and exchange data. It can connect any systems by using different protocols like HTTP, JMS, JDBC etc.
What is Anypoint Platform?
Anypoint platform is a hybrid integration platform which is highly productive, unified and helps to create a smooth distributed systems. It helps to manage full API lifecycles. It provides unified platform to deploy, manage, monitor and rapid development of apps into single place.
What is a Mule Application?
A Mulesoft application is a package of codes and files that runs inside Mule Runtime. Mulesoft application can be triggered with set of events that can be external and inside mulesoft. It can process events and route to next components or endpoints. Endpoints can be external system, another mulesoft application or local resources like file.
A Mule Application may consists of one or more flows, subflows and private flows.
What is the difference between Flow, Subflow, and Private flow?
Flow is a message/event processing block. It can have Mule sources (e.g. an HTTP listener) to trigger the execution of a flow. It can have its own processing strategy and error handling strategy.
Subflow is a scope that enables you to process messages synchronously. It doesn't have any source or error handling block. It inherits the processing strategy and error handling strategy from parent flow. It can be used to split common logic and reusability.
Private flow is a flow without a Mule source. It can be synchronous or asynchronous based on the processing strategy selected. They can have their own error handling strategy.
All three above can be called using a flow-ref. Source will be skipped while calling using flow-ref.
How Mule Applications can be build?
Mule application can be created using online flow-designer and offline by downloading Anypointsudio.
Link for Online flow-designer
Link to download AnypointStudio
How Mule4 Application flow executes?
Mule4 application flows executes events in multiple threads. Mule4 automatically optimizes performance and uses thread switching and parallel processing if required.
Variables in Mule 4 vs Mule 3?
In Mule 3, we had three types of variables: Session variables, Record variables, and Flow variables.
In Mule 4, we only have Flow variables. These variables can be accessed using the keyword "vars".
Example:
vars.variableName
What is API-led connectivity?
API-led connectivity is a methodical way to connect applications to data through reusable APIs. APIs are created in three distinct layers: Experience, Process, and System.
API Life Cycle?
An API life cycle consists of 3 layers:
The first step towards API development is API Specification. This phase involves designing of the API based on the requirements of business. An API Specification is a blueprint of an API.
Anypoint Platform provides Design center to design API's REST interfaces.
The next phase is API Implementation. This phase involves actual implementation of the API.
Anypoint Platform provides Flow Designer which is a web based tool to create a prototype of the API.
Anypoint Studio is the IDE for development and testing of Mule applications.
Final phase in API life cycle is API management, uses a tool named API manager on Anypoint Platform which is used to apply policies to secure APIs and restrict access.
What are the advantages of API-led approach?
- Mulesoft prefers Design first approach for API development that helps non-technical stakeholders easy to understand the API specs/contracts.
- It simplifies the interface between Client and application by hiding complex details.
- Business validation and contracts can be defined at API specification. So, developers don't need to invest time to write code for validation and error type checks.
- It encourages "fail fast" approach which helps in fast and parallel development.
- It encourages reusability of assets and collaboration across teams.
- Apis can be mocked before implementation starts which helps early feedback and parallel development.
- Mulesoft anypoint platform provides tools to write, publish, share and manage versions of API.
What is RAML?
RAML stands for RESTful (REpresentational State Transfer) API Modeling Language. It's a way of describing a RESTful API that is readable by both human and computers.
They use https methods such as GET, PUT, POST, DELETE, etc.
Difference between URI parameters and Query parameters.
URI parameter is used to specify a specific resource whereas Query parameter is used to filter or sort those resources.
let's say we need to filter products based on productType, we use query parameters in this case:
GET: /products?productType=electronics
Let's consider another scenario where we need to retrieve particular product details, we use URI parameters in this case:
GET: /products/{productID}
here, productID will be replaced by a value.
Error Handling in Mule 4?
Error handling in Mule 4 is redesigned. It has three mechanisms to handle errors now.
1. On-Error Propagate: In an On-error Propagate scope, when an error occurs, it terminates the current execution of flow and then throws the error to its parent flow where it's handled.
2. On-Error Continue: In case of an error in an On-error Continue scope, the execution of the flow continues as if successful sending a 200 OK response.
3. Try Catch scope: A Try Catch scope is used to handle errors on individual components. It is especially useful when you need to separate error handling strategies for different components in a flow.
What are the Logger levels?
There are 5 logger levels namely: DEBUG, ERROR, INFO, TRACE, and WARN.
What does scatter-gather return?
A scatter-gather returns a Mule event.
What is the use of Async scope?
Async scope can be used to trigger flows subflows or any components asynchronously from a parent flow. Async scope is very helpful while using logger component or parallel processing requires.
What is the difference between map and mapObject?
map operator is used for array. It takes an array as input and returns an array.
mapObject operator is used for object with key: value pairs. It takes an object as input and returns an object.
map invokes lambda with two parameters: value and index from the input array.
Example:
%dw 2.0 output application/json --- ["apple", "orange", "banana"] map (value, index) -> {
(index) : value
}
Output:
[ { "0": "apple" }, { "1": "orange" }, { "2": "banana" } ]
mapObject invokes lambda with key, value, or index for mapping given object.
Example:
%dw 2.0 output application/json --- {"chandler":"bing","monica":"geller"} mapObject (value,key,index) -> {
(index) : { (value):key}
}
Output:
{ "0": { "bing": "chandler" }, "1": { "geller": "monica" } }
What is batch processing?
Mule allows you to handle large quantities of data in batches.
This is achieved using a Batch job scope which splits messages into individual records, performs actions on records, and reports the results. A Batch job scope processes data asynchronously.
Each batch job contains three different Processing Phases:
1. Load and Dispatch: In this phase, Mule splits the message, creates a Batch Job Instance, a persistent queue and associates it with the Batch Job Instance.
2. Process: This phase does the actual processing of records asynchronously.
3. On Complete: This is an optional phase where you can configure the runtime to create a report or summary of records.
Stay tuned for more!
December 05, 2020

splitBy and joinBy function dataweave2
Hello friends,
In this article I want show you the uses of two very common dataweave functions splitBy and joinBy.
These two functions are very useful while doing transformation with Array and Strings.
Here, we will see how we can use these dataweave functions converting data from String to Array and vice versa.
splitBy
Splits a string into a string array based on a value of input or matches part of that input string. It filters out the matching part from the returned array.
A string or a Java regular expression used to split the string. If it does not match some part of the string, the function will return the original, unsplit string in the array.
splitBy(String, Regex): Array<String>
Example 1: ------------------------------ Input Hello World ------------------------------ Dataweave 2.0 Expression ------------------------------ %dw 2.0 output application/java --- "Hello World" splitBy(/\s/) ------------------------------ Output [Hello, World]
splitBy(String, String): Array<String>
Example 2: ------------------------------ Input Manish Kumar ------------------------------ Dataweave 2.0 Expression ------------------------------ %dw 2.0 output application/java --- payload splitBy(" ") ------------------------------ Output [Manish, Kumar]
The regex/separator can match any character in the input. splitBy performs the opposite operation of joinBy.
joinBy
joinBy function Merges an array into a single string value and uses the provided string as a separator between each item in the list.
You can use joinBy Dataweave 2.0 function to convert array to string.
Example 3: ------------------------------ Dataweave 2.0 Expression ------------------------------ %dw 2.0 output application/json --- { "joinName" : ["Manish","Kumar"] joinBy "-" } ------------------------------ Output { "joinName": "Manish-Kumar" }
joinBy performs the opposite task of splitBy.
Happy Learning :)
December 01, 2020

Array comparison use case Dataweave2
In this article we will see one of the common and challenging real-time use-case in IT industry during application development where we require to compare between arrays. These arrays could be from two different source or api responses.
Here we will see how we can compare two arrays results/payloads and get required results. Also we will see the complete example of our use-case.
To achieve this we will see how we can use the combination of some dataweave functions and how we can utilise these functions for our use-case.
- flatMap
- filter
- contains
- partation
Method I:
flatMap
filter
filter(Array<T>, (item: T, index: Number) -> Boolean): Array<T>
It comes under dw::Core package from dataweave library. It produces output as array.
Method II:
contains
contains(Array<T>, Any): BooleanIt comes under dw::Core package from dataweave library. It returns true if an input contains a given value, false if not.
This version of contains accepts an array as input. Other versions accept a string and can use another string or regular expression to determine whether there is a match.
partation
partition(Array<T>, (item: T) -> Boolean): { success: Array<T>, failure: Array<T> }It comes under dw::core::Arrays package from dataweave library.
It separates the array into the elements that satisfy the condition from those that do not.
Elements that satisfies conditions will come under "success" array partation and which it don't satisfy comes "failure" array partation. So, you can retrieve the matching results under "success" partation node.
Note: Introduced in DataWeave 2.2.0. Supported by Mule 4.2 and later.
May 17, 2020

Dataweave useful String functions-Part1
Hello friends, In this article we will see some common dataweave String functions from String core package(dw::core::Strings) along with their use-cases.
To use these functions in dataweave scripts we need to add/import the module header as below.
you can either import complete package by using * or if you want to use specific function you can use just function name in place of placeholder as given below <functionName>
%dw 2.0
import * from dw::core::Strings or import <functionName> from dw::core::Strings
output application/json
---
{}
Here, we will see 4 common String functions and their usage.
- capitalize(String): String
- camelize(String): String
- dasherize(String): String
- underscore(String): String