Training and certification:
https://training.mulesoft.com/
Course|MuleSoft.U Development Fundamentals (Mule 4):https://training.mulesoft.com/course/mulesoftu-fundamentals4
MuleSoft Documentation:
https://docs.mulesoft.com/general/
Training forums:https://help.mulesoft.com/s/training-groups
https://docs.mulesoft.com/mule-runtime/latest/dataweave-cookbook
https://docs.mulesoft.com/mule-runtime/3.9/mule-expression-language-reference
MuleSoft Certified Developer - Level 1 (Mule 4)
DataWeave
DataWeave is the MuleSoft expression language for transforming data as it travels through a Mule application.
Database expression transforms the input to the output
第一种,是个对象数组,
payload map ( payload01 , indexOfPayload01 ) -> {
ID: payload01.ID,
code: (payload01.code1 default "") ++ (payload01.code2 default ""),
price: payload01.price default 0,
departureDate: payload01.takeOffDate as String default "",
origin: payload01.fromAirport default "",
destination: payload01.toAirport default "",
emptySeats: payload01.seatsAvailable default 0,
plane: {
"type": payload01.planeType default "",
totalSeats: payload01.totalSeats default 0
}
}
第二种,对象数组外面,包了items对象,
items: payload.books map ((item, index) -> {
category: "book",
price: item.price as Number,
id: index,
properties: {
title: item.title,
author: item.author,
year: item.year as Number
}
}
)
{
"items": [
{
"category": "book",
"price": 30.00,
"id": 0,
"properties": {
"title": {
"-lang": "en",
"#text": "Everyday Italian"
},
"author": "Giada De Laurentiis",
"year": 2005
}
},
{
"category": "book",
"price": 39.95,
"id": 3,
"properties": {
"title": {
"-lang": "en",
"#text": "Learning XML"
},
"author": "Erik T. Ray",
"year": 2003
}
}
]
}
dataWeave Reference
lookup
lookup(flowName,payload,timeoutMillis)
lookup(String, Any, Number)
This function enables you to execute a flow within a Mule app and retrieve the resulting payload.
e.g.:Mule::lookup(‘flow2’, {test:'hello '})
core components
scatter-gather component
Each of these routes uses a separate thread to execute the event processors
所以是并行处理的。
Mule Event
A Mule Event is composed of these objects:
A Mule Message contains a message payload and its associated attributes.
Variables are Mule event metadata that you use in your flow.
Mule message
The Mule message is the data that passes through an application via one or more flows. It consists of two main parts:
Validators>Validations Module
The Validations module provides an easy out-of-the-box way to verify that the content of a message in your flow matches a given set of criteria.
RAML
The API needs to be updated using the company-wide standard for the Plan data type. The Object
data type has already been published in Anypoint Exchange with the global reference .
ACME/DataTypes/PlanDataType.raml.
What is a valid RAML specification that reuses the Plan data type?
API Designer>
Using !include
To modularize the API definition, RAML provides several mechanisms, one of which is the !include property. To keep the API definition concise, you can include external content, such as documentation, schemas, and frequently used patterns outside the definition itself. The parser interprets !include as if the content of the externally-hosted file or a URL were declared in-line.
API Manager>
Service Level Access (SLA)
API Proxy
DWL (DataWeave language)
Create Custom Modules and Mappings
详见0323,Mule event has variables and Mule message
Batch Aggregator
You can use the batch aggregator scope to accumulate a subset of records from a batch step, and bulk upsert them to an external source or service.
For example, rather than upserting each lead (i.e., record) in a batch to Salesforce, you can configure a Batch Commit to accumulate, say, 200 records and then upsert all of them to Salesforce in one chunk.
:step name="Step2">
:aggregator size="200">
:create type="Lead" .../>
:aggregator>
:step>
Logger Component
This Core component helps you monitor and debug your Mule application by logging important information such as error messages, status notifications, payloads, and so on. You can add a Logger anywhere in a flow, and you can configure it to log a string that you specify, the output of a DataWeave expression you write, or any combination of strings and expressions.
Keep in mind that the Logger is one of the only components that supports mixing Strings and expressions within a value. DataWeave String interpolation or concatenation within a single expression should be used elsewhere.
The configured messages are logged to the app’s log file, which is located in MULE_HOME/logs/.log if no custom log file path is specified in the log4j2.xml file.
In Studio, the logs show in the Console.
:listener-config name="HTTP_Listener_Configuration" host="localhost" port="8081"/>
-example-Flow">
:listener config-ref="HTTP_Listener_Configuration" path="/"/>
-payload value="Hello MuleSoft!"/>
#[payload]" level="INFO"/>
>
Deploy Applications to CloudHub
>
>org.mule.tools.maven >
>mule-maven-plugin >
>3.3.2 >
>true >
>
>
>https://anypoint.mulesoft.com >
>${app.runtime} >
>${username} >
>${password} >
>${cloudhub.application.name} >
>${environment} >
>
>value >
>
>
>
>
CloudHub Deployment Reference
Top-Level element
If you need to set properties for the Mule application you are deploying, you can use the top-level element:
>
>value >
>
For example:
>
>8081 >
>
同第9题,Create Custom Modules and Mappings
#[payload.year]
#[payload=='US']
同第3题,
lookup(flowName,payload,timeoutMillis)
%dw 2.0
var testXml = typeOf(payload)
var testJson = typeOf({test:'hello'})
var testStr = typeOf('a string')
var testArray = typeOf(['hello','world'])
var testNumber = typeOf(100)
output application/json
---
{
testXml:testXml,
testJson:testJson,
testStr:testStr,
testArray:testArray,
testNumber:testNumber
}
Output如下:
{
"testXml": "Object",
"testJson": "Object",
"testStr": "String",
"testArray": "Array",
"testNumber": "Number"
}
#[message.attributes.queryParams.firstName]
相当于
#[attributes.queryParams.firstName]
The For Each scope stores each item of the collection in payload during each iteration.
这几天沉迷于追剧不可自拔,老友记看到不亦乐乎还有最终幻想7重制版的剧情也不能错过,妹子美的快要掰弯我了顺便还看了几集甄嬛和延禧。。
在这里我深刻反省一下!
输出格式如下:
{
"account_id": "KA-1",
"name": "Max Mule",
"position": "sell",
"write_date": "2020-04-27T22:34:31.655+08:00"
}
accessible,payload可以,但vars.quantity和queryParams都丢失了
第46题参考:How-to-set-SOAP-header-for-Mule-4-Web-Service-Consumer
47.Validations Module
Validate Null:
Fails if the value is not null and not an instance of NullPayload
payload != null => fail => response:Validation Error
Validate Is Blank String, 也是可能的考点。
48.On Error Continue
Executes and uses the result of the execution, as the result of its owner, as if the owner had actually completed the execution successfully.
If a transaction is being handled, it would be committed as well.
On Error Propagate
Executes but propagates the error to the next level up, breaking the owner’s execution.
If a transaction is being handled, it’s rolled back.
%dw 2.0
output application/xml
var conductorsId = [592,921]
---
trains:
{(
conductorsId map( (engId, index)->{
train:{
engineerId:engId
}
})
)}
<?xml version='1.0' encoding='UTF-8'?>
>
>
>592 >
>
>
>921 >
>
>
51.
52.
validation:is null -> Error Propagate -> flow’s error handler(Error Continue)
Try Scope
In the case of On Error Propagate, the error is propagated to the flow’s error handler, as if the Try scope did not exist.
In the case of On Error Continue, processing continues outside the Try scope at the next flow component, as if the Try scope never threw an exception.
搭建ftp服务器:win10需要打开IIS,在IIS里添加ftp站点;创建新用户,把该站点的物理路径权限给到新用户;还要配置一下防火墙。
55.同第42题,For Each Scope的payload类似于局部变量,
#['MuleSoft' == payload.company]
57.http://localhost:8081/accounts/123
attributes.uriParams.employeeID如下图所示:
58.http://localhost:8081/accounts?account_type=retail&industry=finance
#["The payload is:" ++ payload]
The payload is:#[payload]
两者应该是等价的。
对比第45题,accessible,payload、vars.quantity和queryParams都还在。
61.Config Properties
Use the Properties in your Application
Once you have configured your properties file and added it to your project, you can reference its attributes by using a syntax like this: ${propertyContainer.propertyName}.
Based on the examples configured in the previous section, to use the path and port values the syntax is ${http.path} and ${http.port} respectively.
For example, you can configure your Global HTTP Request configuration to use the values defined in the properties file.
<http:request-config
name="HTTP_Request_config"
doc:name="HTTP Request
configuration" doc:id="7120494c-0540-4ad1-a118-f5b6db3f1456"
basePath="${http.path}" >
<http:request-connection
host="${http.host}"
port="${http.port}" />
</http:request-config>
拒绝狗粮,从我做起(手动狗头)
https://docs.mulesoft.com/mule-runtime/4.1/mule-app-properties-to-configure
63.
64.map(Array, (item: T, index: Number) -> R): Array
Transforms items from the given list (array) into a new list using the specified mapper function.
66.Step 2. Design an API Specification
Example: Setting Up Watermarks with an Object Store
69.