MuleSoft Development
How to achieve the parallel processing in MuleSoft?
To achieve the parallel processing you can use scatter gather or batch job and with mule 42 on wards there is also parallel for each has been added to process the message simultaneously, Please visit scatter gather and parallel for each urls for more information
How to invoke the Custom Java Class from inside a dataweave
%dw 2.0 Import java!com.mycompany::classname output application/json --- { a: classname::methodName("myString") }
How to access secure property inside dataweave?
By using p(‘secure::<property name>’) you can access the secure property defined as part of secure property file in mule application – more information
How can you raise error explicitly in Mule flow/subflow?
By using the Raise Error component you can explicitly raise the error in between the flow more information
How can you handle errors in middle of the processing in MuleSoft?
You can use the Try block to handle the errors in between the flows, try block also support the transaction. By using try block you can use the on-error continue or on-error propagate to handle the error more information
How to call Flow from inside a dataweave?
You can use dataweave lookup function to call flow from inside a dataweave It works in Mule apps that are running on Mule Runtime version 4.1.4 and later It takes the flow’s name and an input payload as parameters. For example, lookup(“flowname”, payload)
What is the difference between map, mapObject and pluck?
- map is used to iterate over array
- mapObject is used to iterate over object and return object
- pluck iterates over an object and returns an array of keys, values, or indices in that object.
How will you combine 2 arrays into single array in MuleSoft?
You can use flatten dataweave function to combine two arrays in to single array
What are target variable in MuleSoft
When creating a flow in mule app, you can store data in variable so that any component in a flow can use it. In Mule 4 Target Variable replaces the Message Enricher of Mule 3, target variable is available with most of the connectors
How many phases are there for batch job in Mule 4
Each batch job contains 3 different Phase
-
- Load and Dispatch.
- Process
- On Complete.
When we should use batch processing
You can use batch processing when:
-
- Synchronizing data sets between business applications, such as syncing contacts between two different ERPs
- Extracting, transforming and loading (ETL) information into a target system, such as uploading data from a flat file (CSV) to Hadoop.
- Handling large quantities of incoming data from an API into a different systems
Why we use Batch Aggregator scope
Batch Aggregator scope is used to accumulate a subset of records from a batch step and process them to external source or service for example rather than processing single record to target system you can use batch aggregate to process all the records at once. You can also configure batch aggregator scope to process fixed size groups of records inside a batch aggregator scope
What is the difference between For each and Batch Process
For each do the processing in single thread while Batch Process performs multi-threaded processing moreinformation
How to manage the Transaction in MuleSoft
MuleSoft supports two types of transactions
-
- Single resource( Local)
- XA transactions (extended architecture)
You can configure the transaction depends on the requirement
You can start a transaction from a message source. In this case, the entire flow takes part in transaction This is useful when working with messaging connectors to prevent the consumption of the message if a problem occurs when processing it, allowing you to retry later (because of the rollback).
You can also use the Try block which support the transaction when you want to handle the transaction in middle of the flow
There are below transaction Action define the type of action that operations take regarding transactions
-
- Always_Begin
- Always_Join
- Begin-or-join
- Join-if-possible
- Indifferent
- None
- Not Supported
Please visit this url for more information
What are various types of error handling in Mule 4?
Mule 4 has redesigned error handling by introducing the error-handler component, which can contain any number of internal handlers and can route an error to the first one matching it. Such handlers are on-error-continue and on-error-propagate.
How can you process message asynchronously in MuleSoft?
You can use the Async Scope to process the message asynchronously. – more information
Async can be used to do the processing in parallel with the main flow, it can be used to process the time consuming operations that does not expect a response back
How can you achieve the Reliability in MuleSoft?
If your application uses a transactional transport such as JMS, VM, DB etc. Reliable messaging is ensured by the built in support of transactions in the transport. Reliable messaging pattern is important when dealing with non-transactional endpoints
How can you improve performance of Mule Application in MuleSoft?
There are multiple ways to improve the performance
-
- Try to save the result and reuse them later
- If processing is expansive do it only once and save result and use them later
- Try to put the validation at start of the flow
- Use Streaming to process data
- Try to process the data asynchronously wherever is possible
How can you optimize memory efficiency of the Code in MuleSoft?
-
- Do not save the Payload in to the flow Variable as it is more memory consuming element
- Do not load unnecessary part of the document
- Use better Database polling for highly concurrent scenarios
What is distributed file polling?
In mule 4 distributed file polling is used to poll files in cluster nodes
There are few connectors where this feature is enabled by default
You can configure connectors to poll only from primary node @primaryNode Only which ignores the default setting set by mule runtime engine
How will you implement caching in MuleSoft?
There are 2 ways to implement the caching in MuleSoft
-
- Use Object Store – more information
- Use Cache scope to cache the Response – more information
If we wanted to process only one message at a time in mule flow how can we achieve that?
we can make a flow to process in single thread, there is an option to define the Max Concurrency you can configure the same as 1 to process only one message at a time
how to incremental way of data insert/update