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
A web client submits a request to http://localhost:8081?flrstName=Mahesh. What is the correct
DataWeave expression to access the firstName parameter?
Correct answer is below as it follows the required syntax
#[attributes.queryParams.firstName]
A mule project contains MySQL database dependency . The project is exported from Anypoint Studio so that it can be deployed to Cloudhub. What export options needs to be selected to create the smallest deployable archive that will successfully deploy to Cloudhub?
Correct answer is select the Include project modules and dependencies option. This option adds up bundling the actual modules and external dependencies required to run the Mule application in a Mule runtime engine. Attach Project Sources is an optional thing to include metadata that Studio requires to reimport the deployable file as an open Mule project into your workspace.
A Utlility.dwl is located in a Mule project at src/main/resources/modules. The Utility.dwl file defines a function named encryptString that encrypts a String What is the correct DataWeave to call the encryptString function in a Transform Message component?
Correct answer is the below one as it follows the correct syntax.
%dw 2.0
output application/json
import modules::Utility
—
Utility::encryptString( “John Smith” )
Refer to exhibits. A web client submits a request to http://localhost:8081. What the structure of the payload at the end of the flow?
Scatter-Gather sends the event to each routes concurrently and returns a collection of all results. Collection is an Object of Objects. Each object contains attributes and payload from each Mule event returned from a flow.
Hence correct answer is
[
“0”: {
“attributes”: —,
“payload”: “Banana”
}
“1”: {
“attributes”: —,
“payload”: “Banana”
}
]
Refer to the exhibits. The main flow contains an HTTP Request in the middle of the flow. The HTTP Listeners and HTTP Request use default configurations. What values are accessible to the Logger at the end of the main flow after a web client submits the request to http://localhost:8080/order?color=red?
In this case as outbound call is made using HTTP: POST /child , all attributes will be replaced by this invocation. Hence query parameter will not be accessible at logger. Hence correct answer is
payload
quantity var
Refer to the exhibits. What is valid expression for the Choice router’s when expression to route the events to the domesticShipping flow
Correct answer is #[payload == ‘US’] as this follows the correct syntax
Assume that you are invoking Mulesoft API using Postman tool. Mulesoft API follows standard HTTP status code conventions correctly. If service returns an error with HTTP code 401. What can be concluded from this response?
The HTTP 401 Unauthorized client error status response code indicates that the request has not been applied because it lacks valid authentication credentials for the target resource.
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]
A Database On Table Row listener retrieves data from a CUSTOMER table that contains a primary key userid column and an increasing systemin_date_time column. Neither column allows duplicate values. How should the listener be configured so it retrieves each row at most one time?
You can set systemin_date_time column as watermark column in DB listener configuration as this field is increasing field.
The Database Select operation returns five rows from a database. What is logged by the Logger component?
Array is the correct answer as select DB operation returns array of objects
Refer to the exhibits. The two Mule configuration files belong to the same Mule project. Each HTTP Listener is configured with the same host string. Port number , path and operation values are shown in display names. What is the minimum number of global elements that must be defined to support all these HTTP Listeners?
In this case three configurations will be required each for port 8000, 6000 and 7000
Hence correct answer is 3
Refer to the exhibit . What is the correct syntax to add an employee ID as URI parameter in an HTTP Listener path
While configuring HTTP listener path , URI parameters are always enclosed within curly braces.
Hence correct answer is {employeeID}
What path setting is required for an HTTP Listener endpoint to route all requests to an APIKit router
Correct answer is /* as this is correct syntax to configure HTTP Listener endpoint
While configuring HTTP listener in Anypoint platform project in a flow , which of the following is NOT mandatory to be configured for getting the code compiled successfully?
Allowed methods for HTTP Listener is an optional field which can be used to restrict the HTTP method which will be accepted.
For e.g. If you define allowed method as POST and request is received with method PUT then request will be rejected with below error.
HTTP response with status code 405 Method Not Allowed.
Refer to the exhibits. The Batch Job processes, filters, and aggregates records. What is the expected outcome from the Logger component
Batch scope has filter criteria which says payload mod 2 = 0 which means only 2, 4 and 6 will be in batch scope. So payload for each of these will be incremented by 10. Aggregator has batch size defined as 2. So it will process in batch of two records.
Hence correct answer is
[20,40]
[60]
In the execution of the Scatter-Gather , the flow route completes after 10 seconds and the flow2 route completes in 40 seconds. How many seconds does it take for the Scatter-Gather to complete?
Scatter-Gather sends the event to each routes concurrently. Hence both route in this example will start in parallel. So total time to complete processing is 40 seconds which is the correct answer
What should the the first line of RAML API definition contain?
RAML specifications always start with the comment containing RAML version. Please find the sample below
#%RAML 1.0
What HTTP status code does the HTTP specification indicate to be returned when an unsupported value is sent in the Accept Header?
503
The HyperText Transfer Protocol (HTTP) 406 Not Acceptable client error response code indicates that the server cannot produce a response matching the list of acceptable values defined in the request’s proactive content negotiation headers, and that the server is unwilling to supply a default representation.
Proactive content negotiation headers include:
Accept
Accept-Charset
Accept-Encoding
Accept-Language
While creating notebook, what is the syntax of the first function call to generate a client to make calls to the API?
Syntax for createClient command is as below
API.createClient(alias, url, options? cb?)
alias :The name with which you call this client from now on (Required)
url :A URL that directs to the API’s RAML definition (Required)
options: A specification of default headers, a fallback body, or other option. Type the method in the notebook and place the cursor on this argument for more details. (Optional)
cb :Pass in a custom callback to run when the client has loaded (Optional)
Sample example is as below
Which of the following HTTP method should NOT be idempotent in nature?
HTTP methods are classified as following:
+———+——+——-
| Method || Idempotent |
+———+——+——-
| CONNECT || no |
| DELETE || yes |
| GET || yes |
| HEAD || yes |
| OPTIONS || yes |
| POST || no |
| PUT || yes |
| TRACE || yes |
+———+——+——-
What is true about RESTful API’s
As per the REST architecture, a RESTful Web Service should not keep a client state on the server. This restriction is called Statelessness. It is the responsibility of the client to pass its context to the server and then the server can store this context to process the client’s further request.
Which is NOT a valid fragment identifier in RAML 1.0?
Extension is the correct answer
API fragment is one of the following types defined by RAML.org.
Trait
Resource Type
Library
Type
User Documentation
Example
Annotation Type
Security Scheme
What is the correct way to specify queryParameter in RAML 1.0?
Correct syntax is
/flights:
get:
queryParameters:
destination:
required: false
enum:
– SFO
– LAX
– CLE
What language is used to create API Notebooks?
JavaScript is the correct answer as An API Notebook is a web-based tool for building interactive tutorials and examples in a JavaScript scripting workspace