MCD Level 1 - Part 2 Flashcards
According to Mulesoft, how are Modern APIs treated as?
Modern API has three features 1) Treated as products for easy consumption 2) Discoverable and accessible through self-service 3) Easily managed for security , scalability and performance
What is the difference between a subflow and a sync flow?
Correct answer is Subflow has no error handling implementation where as sync flow has.
Using Flows
Flows can have Mule Sources (such as an HTTP listener receiving a request) that trigger the execution of a flow. For cases where you do not want a source to start a flow right away, you can configure your flow as initially stopped and start it later through Runtime Manager.
Like functions or methods in other programming languages, it is a best practice to focus your flows on specific (perhaps reusable) activities, such as receiving an API request from a web client, processing the event, then returning an appropriate response. If the event processing gets complicated, or must call out to other services, you might factor out that behavior into other flows.
Using Subflows
A subflow is a scope that enables you to group event processors in a manner similar to that of a flow, but with certain differences and limitations:
Subflows do not have event sources.
Subflows do not have an error handling scope.
During design, subflows work as macros that replace the Flow Reference components that call them.
When you build the application, all Flow Reference components that call a subflow are replaced by the contents of the referenced subflow.
Referencing subflows results in better performance than referencing a flow.
What can be added to the flow to persist data across different flow executions?
Object stores are used to store and persist the data across different flow executions.
Hence correct answer is Key/value pair in Object store
https://docs.mulesoft.com/runtime-manager/managing-application-data-with-object-stores
Mule application contains two HTTP Listeners, each configured for different API endpoints: http://trainingdemo.com/apis/orders and http: //trainingdemo.com/apis/customers. What base path value should be set in an HTTP? Listener config element so that it can be used to configure both HTTP Listeners?
C. /apis/
Explanation:
/apis/* would match any path starting with “apis/” and any characters after that, which is more than what we need.
/apis/? wouldn’t work because the question specifies that the base path should be used to configure both HTTP Listeners, and this option only matches paths ending with a question mark.
/apis/orders|customers is too specific and wouldn’t work for other potential endpoints under the “/apis/” path.
Therefore, /apis/ is the most appropriate option because it:
Matches the common prefix of both desired endpoints (/apis/orders and /apis/customers).
Captures only the desired base path without unnecessary characters or wildcards.
Allows for flexibility to add additional endpoints under the “/apis/” path in the future without modifying the base path configuration.
As a part of requirement , application property defined below needs to be accessed as dataweave expression. What is the correct expression to map it to port value?
{ port : p(‘db.port’)}
In a DataWeave script you can reference an application property defined in a properties files by using the p function of the dw::Mule module. The module is imported by default.
So when using Dataweave expression to use the value used in application properties, it is correct syntax.
Please refer to the below link for Mulesoft documentation around this.
https://docs.mulesoft.com/mule-runtime/4.3/dw-mule-functions-p
What valid RAML retrieves details on a specific order by its orderId as a URI parameter?
Correct answer is below as it is the correct syntax
/orders:
/{orderId}:
get:
What is the correct DataWeave expression for the Set Payload transformer to call the createCustomerObject flow with values for the first and last names of a new customer?
Now as per lookup function syntax the first argument to this function is the name of the flow to be called and second argument is payload to be sent as a map.
Hence correct answer is.
lookup( “createCustomerObject”, {first: “Aice, last: “Green”})
A webclient submits the request to http://localhost:8081/flights?destination=SFO and the Web Service Consumer throws a WSC:BAD_REQUEST error. What is the next step to fix this error?
A webclient submits the request to http://localhost:8081/flights?destination=SFO and the Web Service Consumer throws a WSC:BAD_REQUEST error. What is the next step to fix this error?
Refer to the exhibit. The API needs to be updated using the company wide standard for the Plan data type. The Object data type has already been published to Anypoint Exchange with the global reference ACME/DataTypes/PlanData.raml . What is valid RAML specification that reuses the Plan Data type?
RAML keyword to use a reference is !include. Hence two of the options which contain referrence in plan field are incorrect as they contain the keyword reference instead of include.
Also references to data types are included under type field and not dataType field.
Hence correct answer is
#%RAML 1.0
title: ACME Telecom API
types:
Plan: !include ACME/DataTypes/PlanDataType.raml
/plans:
get:
responses:
200:
body:
application/json:
type: Plan[]
example: !include ACME/Examples/PlanExamples.raml
Refer to the exhibits. What expression correctly specifies input parameters to pass the city and state values to SQL query?
Correct syntax is as below. You can also get detail of such examples at below link
https://docs.mulesoft.com/db-connector/1.9/database-connector-examples
#[{
city: “San Fransisco”,
state: “CA”
}]
Refer to the exhibits. How many private flows does APIKIt generate from RAML specification?
APIKIt Creates a separate flow for each HTTP method. Hence 4 private flows would be generated
What is the correct syntax to define and and call a function in Dataweave?
fun addKV( object: Object, key: String, value: Any) = object ++ {(key):(value)} — addKV ( {“hello’: “world”}, “hola”, “mundo” )
Keyword to ad function in Dataweave transformation is fun. This makes two of the above options incorrect. Also parameters needs to be passed exactly in same order as defined in function definition.
Hence correct answer is
fun addKV( object: Object, key: String, value: Any) =
object ++ {(key):(value)}
—
addKV ( {“hello’: “world”}, “hola”, “mundo” )
A web client submits a request to http://localhost:8081?accountType=personal.The query parameter is captured using a Set Variable transformer to a variable named accountType. What is the correct Dataweave expression to log accountType?
vars: Keyword for accessing a variable, for example, through a DataWeave expression in a Mule component, such as the Logger, or from an Input or Output parameter of an operation. If the name of your variable is myVar, you can access it like this: vars.myVar
Hence correct answer is Account Type : #[vars.accountType]
What is correct syntax for a Logger component to output a message with the contents of a JSON Object payload?
Correct answer as as below it concatenates payload with String.
The payload is: #[payload]
. What DataWeave expression transforms the example XML input to the CSV output?
payload.sale.*item map {(value, index) -> { index: index, sale: value.@saleId itemName: value.desc, itemPrice: (value.price) * (value.quantity) item: value.@itemId
What is valid text to set the user field in the Database connector configuration to the username value specified in the config.yaml file?
Below is the correct answer as it adheres to the correct syntax to access application properties.
${db.username}
What is the output payload in the On Complete phase
This is a tricky question. On complete phase payload consists of summary of records processed which gives insight on which records failed or passed. Hence correct answer is
Summary statistics with No record data
Details can be found at below documentation
https://docs.mulesoft.com/mule-runtime/4.3/batch-processing-concept#on-complete
A flow contains an HTTP Listener as the event source. What is the DataWeave expression to log the Content-Type header using a Logger component?
Such questions are best solved with filtering mechanism
1) Concatenation is always with ++ sign and not with + sign which makes two of the options as incorrect
2) headers can be accessed with attributes.headers and not with only headers
Hence correct answer is
#[“Content-Type: ” ++ attributes.headers.’content-type’]
Refer to the exhibit. A web client submits a request to the HTTP Listener and the HTTP Request throws an error. What payload and status code are returned to the web client?
When HTTP Request throws an error, it goes in error handling section. Note here that On Error Continue scope is being used here is error flow. When On Error Continue scope is invoked, all the processors in error block are executed and success response is sent back to the client with payload which is set in error flow. In this case payload is set to “Error” value in error block. Hence it will be sent back to client with http code as 200 as On error continue always sends success error code. Hence correct answer is
Response body: “Error” Default response status code: 200
A RAML example fragment named StudentExample.raml is placed in the examples folder in an API specification project. What is the correct syntax to reference the fragment?
Correct answer is
examples: !include examples/StudentExample.raml
The !include tag takes a single argument: the location of the external file containing the property value. This location may be an absolute URL, a path relative to the root RAML file
A location starting with a forward slash (/) indicates a path relative to the location of the root RAML file, and a location beginning without a slash is interpreted to be relative to the location of the including file.
What module and operation will throw an error if a Mule events payload is not number
Correct answer is Validation modules Is Number operation.
This processor validates that a String can be parsed as a number of a certain type.
Note that private flow has error scope defined as On Error Continue . So when error occurs in private flow , it is handled by this On Error Continue scope which sends success response back to main flow and does not throw back an error. So main continues normally and payload is set to Success – main flow.
Hence correct answer is Success – main flow
Note that private flow has error scope defined as On Error Continue . So when error occurs in private flow , it is handled by this On Error Continue scope which sends success response back to main flow and does not throw back an error. So main continues normally and payload is set to Success – main flow.
Hence correct answer is Success – main flow
Refer to the exhibit. The error occurs when a project is run in Anypoint Studio. The project, which has a dependency that is not in the MuleSoft Maven repository, was created and successfully run on a different computer. What is the next step to fix the error to get the project to run successfully?
As dependency is not present in Mulesoft Maven repository, we need to install the dependency on computer’s local Maven repository. Install the dependency to the computer’s local Maven repository is correct choice.
What values are accessible in the child flow after a web client submits a request to http://localhost:8081/order?color=red?
Correct answer is as below as all of it will be accessible in child flow.
payload
quantity var
color query param