MCDLevel1Fundamentals Flashcards
how do you define function in dw 2, whats keyword?
TODO: there are more ways here https://docs.mulesoft.com/dataweave/2.3/dataweave-functions
its "fun" like in fun myFunction(param1, param2, ...) =
whats @ used for in dw? and how does it work given. Consider
%dw 2.0 var myVar = read(‘
SomeBrand ‘,
‘application/xml’)
output application/json
{ item: [ { “type” : myVar.product.@.”type”,
“name” : myVar.product.brand,
“attributes”: myVar.product.@ } ] }
XML Attribute Selector (.@myKey)
@, .@keyName
String value of the selected attribute’. Pay attention when something comes after @ vs nothing. .@ take all attributes and represent it as object and not array.
{
“item”: [
{
“type”: “electronic”,
“name”: “SomeBrand”,
“attributes”: {
“id”: “1”,
“type”: “electronic”
}
}
]
}
type of queues in Anypoint MQ?j
1) Standard queue
These queues don’t guarantee a specific message order. Standard queues are the best fit for applications in which messages must be delivered quickly.
Anypoint MQ supports up to 120,000 in-flight messages per standard queue.
2) FIFO (first in, first out) queue
These queues ensure that your messages arrive in order. FIFO queues are the best fit for applications requiring strict message ordering and exactly-once delivery, but in which message delivery speed is of less importance. See FIFO Queues.
Anypoint MQ supports 10 in-flight messages per message group in a FIFO queue. Anypoint MQ doesn’t limit the number of message groups in a FIFO queue.
1) What DataWeave 2.0 type can be used as input to a mapObject operation? 2) Whats output given
%dw 2.0
output application/json
—
{“a”:”b”,”c”:”d”} mapObject (value,key,index) -> { (index) : { (value):key} }
1) Object (not map or array or anything)
2) { “0”: { “b”: “a” }, “1”: { “d”: “c” } }
Obs! pay attention to the order of value, key, index
as it can be shuffled on the exam. Remember it as V.K.I , sounds almost like BMI.
what reserved property can be defined and used in a mule application to allow an https listener be accessed by external clients after its deployed to cloudhub?
${https.port}
when calling endpoint like this, how is dw looking query params up? e.g. http://localhost:8081/retrieveQueryParams?Name=John&EmpId=123
%dw 2.0
output application/json
—
{
“Name”:attributes.queryParams.Name,
“EmployeeId”:attributes.queryParams.EmpId
}
when calling endpoint and using uri params, how are they looked up then?
[attributes.uriParams.name]
how is mule 3 #[flowVars.varName] replaced in mule 4?
[vars.varName]
how is mule 3 #[message.inboundProperties.’http.version’] replaced in mule 4?
…in a Transform message:
if (attributes.headers[‘keyname’] != null and attributes.headers[‘keyname’] != “”) attributes.headers[‘keyname’] as String else null
or directly use this in a log:
attributes.headers[‘keyname’]
trait name for specifying client id in raml?
client-id-required
https://docs.mulesoft.com/api-manager/2.x/prepare-raml-task
hur placerar man query parametrar, vad heter den och vilka attribut har de?
/books:
/{bookTitle}
get:
queryParameters:
author:
displayName: Author
type: string
description: An author’s full name
example: Mary Roach
required: false
publicationYear:
displayName: Pub Year
type: number
description: The year released for the first time in the US
example: 1984
required: false
put:
queryParameters:
access_token:
displayName:
is this removing one array from another or removing elements of the array element?
%dw 2.0
output application/json
—
([0, 1] – [0, 2])
//Elements due to minus minus. Result is single element in the first array
[
1
]
what comes first in a filter operation, index or value?
[9,2,3,4,5] filter (value, index) -> (value > 2)
how can you access header, and it doesnt look like attributes.uriParams.X or attributes.queryParams.X or similar?
attributes.header[‘user-agent’]
what does #[payload.*name] and #[payload..name] have in common? and the difference?
common: both return Array with values of key:value pairs
difference: the .* is multi value selector while .. is Descendants selector
What does this Descendants selector return?
%dw 2.0
output application/xml
ns html http://www.w3.org/TR/html4/
ns furniture https://www.w3schools.com/furniture
—
root: {
b: payload.root.furniture#table..name
}
given: TODO: fix pic
just like Single level Explicit Selector, or the Indexed Selector, the Descendants Selector returns the value of the key:value pair that matches the expression.
What does this Multivalue selector return?
%dw 2.0
output application/json
—
payload.users.*user
and given input:
Multi value selector can either be applied over an :object or an :array.
[“Mariano”, “Martin”, “Leandro”]
what does this produce
contains(“names”, “name”)
“nameing” contains “name”
true,
true
mapObject, whats the output?
pay attention its not an array
%dw 2.0
output application/json
—
{“a”:”b” , “c”:”d”} mapObject (value,key,index) -> { (index) : { (value):key} }
{ “0”: { “b”: “a” }, “1”: { “d”: “c” } }
what to do when backpressure error arises?
https://help.mulesoft.com/s/article/Dealing-with-MULE-FLOW-BACK-PRESSURE-error
what does zip operator do in dataweave?
Merges elements from two arrays into an array of arrays.
%dw 2.0
output application/json
—
[0,1] zip [“a”,”b”]
result in
[[0,”a”], [1,”b”] ]