Top DataWeave Interview Questions (2021) | CodeUsingJava
















Most frequently asked DataWeave Interview Questions


  1. What is MuleSoft?
  2. What are the various types of variables used by MuleSoft?
  3. What are the message types in MuleSoft?
  4. What is the meaning of DataWeave?
  5. What is p() used in DataWeave?
  6. How can we invoke or call flows from DataWeave?
  7. How can we ignore empty objects in DataWeave MuleESB?
  8. How do we obtain XML encoding type?
  9. How can we sort descending in DataWeave?
  10. How can we use Excel as a lookup in Dataweave?


What is MuleSoft?

MuleSoft is an integration platform that is built in solving data integration needs of modern businesses.MuleSoft also helps in connecting data sources and applications, also in performing ETL Processes and Analytics.It connects Enterprise and SaaS Applications in Cloud and Traditional Data Sources.

What are the various types of variables used by MuleSoft?

Various Types used by variables used by MuleSoft are:
  • Flow Variable used in assigning or in removing variables associated with messages in current flow.
  • Record Variable used inside a Batch Job.
  • Session Variable used in setting and removing variables for completing lifecycle through multiple flows.

What are the message types in MuleSoft?

Message Types used in MuleSoft are as follows:
Bridge Message
Echo and Log Message
Building Messages

What is the meaning of DataWeave?

DataWeave is an expression language used in MuleSoft used in accessing and transforming data which travels through Mule App.It is used in interagting with Mule Runtime Engine, also runs the scripts and expressing in our Mule App.

What is p() used in DataWeave?

p() function is used for reading data from properties files like Database Passwords, HTTP Host, API Keys, etc.
Here's a syntax used for the following:
%dw 2.0 output /json --- { "Application Name": p('name123') }


How can we invoke or call flows from DataWeave?

We use lookup() in invoking or calling flows from DataWeave, used in executing a flow named another flow and in passing the payload to another flow.
Here's a syntax used for the following:
%dw 2.0
output /json
---
{
    Mule: lookup('flow1', {test:'Hi'}
}


How can we ignore empty objects in DataWeave MuleESB?

We can ignore empty objects in DataWeave MuleESB by using the following command:
{
 "address": {
    "city": "bob",
    "company_name": "nike",
    "country_code": "bub",
    "location": {
    "city": void,
    "state": void
  }
}}


How do we obtain XML encoding type?

We can obtain XML encoding type by using the following command:
%dw 2.0
output /java
---
((payload.^String) scan /encoding='([A-z0-9-]+)'/)[0][1]


How can we sort descending in DataWeave?

We can sort descending in DataWeave by using the following command:
(vars.results OrderBy (results) -> results.name)[-1 to 0]



How can we use Excel as a lookup in Dataweave?

For using excel as lookup we need readURL fuction:
var excel = readUrl("classpath://myExcelFile.xlsx", "application/xlsx")
---
(excel.mySheet filter ((entry, index) -> entry.foo == var.foo))[0]