# 31jan2022 - Anypoint Platform Architecture: Integration Solutions
###### tags: `MuleSoftTraining`
[TOC]
## Day 1
### Module 0: :sparkles: æºå
1. [Anypoint Studio 7.11.1 (ææ°ç)](https://www.mulesoft.com/lp/dl/studio)
- ã³ãŒã¹éå§åã«ããŠã³ããŒããšã€ã³ã¹ããŒã«ãè¡ãããœããã®èµ·åãã詊ããã ããã
- ãããããšã©ãŒãšãã©ãã«ã·ã¥ãŒãã£ã³ã°ã¯ãã¡ãããã確èªãã ããã
2. [Mule Runtime 4.4 (ææ°ç)](https://www.mulesoft.com/lp/dl/mule-esb-enterprise)
3. [Advanced REST Client](http://install.advancedrestclient.com/install)
- Postman ãªã©ãä»ã® REST API ã¯ã©ã€ã¢ã³ãã¢ããªã±ãŒã·ã§ã³ã䜿çšå¯èœã§ãã
4. [Anypoint Platform ãã©ã€ã¢ã« (詊çš) ã¢ã«ãŠã³ã](https://salesforce.quip.com/QQN7Acqju0il)
5. [Java 8/11 (Adopt OpenJDK)](https://salesforce.quip.com/5B2PAV46QbB5)
6. [VisualVM](https://visualvm.github.io/)
7. [Apache JMeter](https://jmeter.apache.org/download_jmeter.cgi)
8. [Anypoint CLI](https://docs.mulesoft.com/jp/runtime-manager/anypoint-platform-cli#%E3%82%A4%E3%83%B3%E3%82%B9%E3%83%88%E3%83%BC%E3%83%AB)
``npm install -g anypoint-cli@latest``
```anypoint-cli``` >>> ã¢ã¹ããŒã¢ãŒãã®è¡šç€ºåŸããšã©ãŒã§ãããã° OK!
- [Git](https://git-scm.com/book/ja/v2/%E4%BD%BF%E3%81%84%E5%A7%8B%E3%82%81%E3%82%8B-Git%E3%81%AE%E3%82%A4%E3%83%B3%E3%82%B9%E3%83%88%E3%83%BC%E3%83%AB) ã®ã€ã³ã¹ããŒã«ãå¿
èŠã«ãªããŸãã
``git --version`` >>> git ã®ããŒãžã§ã³ãè¿ã£ãŠããã° OK
- [Node.js](https://nodejs.org/ja/download/) ã®ã€ã³ã¹ããŒã«ãå¿
èŠã«ãªããŸãã
``npm -v`` >>> npm ã®ããŒãžã§ã³ãè¿ã£ãŠããã° OK
#### ãã£ã¬ã¯ããªã®æºå
MuleTrainingIntSol_30jan2021
- exportedApps
- installs
- performance
- archive
- input
- output
- sampleData
- workspace
- mule-node1(Mule Runtime v4.4)
- mule-node2(Mule Runtime v4.4)
- mule-ee-distribution-standalone-4.4.0.zip (ããã¯ã¢ãã)
- **:star:APAIntSols4.4_studentFiles_16nov2021.zip**
- APAIntSols4.4_studentSlides_JA_16nov2021.zip
- APAIntSol4.4_studentManual_JA_16nov2021.pdf
from Yamazaki san: Q. åããæ°ã«ãªã£ãã®ã§ããããŠãŒã¶ã¯åé€ã§ããªã仿§ã§ããããïŒ
ãã©ã€ã¢ã«ã®ãŠãŒã¶ãæºãŸã£ãŠããŠããŸã£ãŠãããã«ããããšæã£ãŠèª¿ã¹ãŠãã®ã§ãããã©ãããŠãŒã¶ã¯åé€ã§ããªãã®ããªãšæããŸããŠã
- [ãã©ã€ã¢ã«ã¢ã«ãŠã³ãã®å逿¹æ³](https://help.mulesoft.com/s/article/How-to-Delete-a-Trial-Organization-from-Anypoint-Platform)
1. åé€ããããŠãŒã¶ãŒãæ°çµç¹ã«æåŸ
ãã
2. æ§çµç¹ãããŠãŒã¶ãŒãããªããªãã®ã§ããã°ãçµç¹èªäœãåé€ããããèããã
3. æ°çµç¹ã® Access Management ã§ãŠãŒã¶ãŒãåé€

### Module 1: :sparkles: ã€ã³ãã°ã¬ãŒã·ã§ã³ãœãªã¥ãŒã·ã§ã³ã¢ãŒããã¯ãã£ã®ç޹ä»
#### Catalyst Knowledge Hub
(æ§) https://catalyst.mulesoft.com/
(æ°) https://knowledgehub.mulesoft.com/s/
æ¥æ¬èªã! https://knowledgehub.mulesoft.com/s/global-search/%40uri#q=JP&sort=relevancy
- [CI ãŠã§ãããŒ](https://knowledgehub.mulesoft.com/s/article/Continuous-Delivery-Webinar-JP)
#### Catalyst Git Repository
https://github.com/mulesoft-catalyst
äŸ:) ç£æ»ãã° (audit log) ã splunk ã«éçŽããã
- [catalyst](https://knowledgehub.mulesoft.com/s/article/Retrieve-Audit-Logs-Aggregate-and-Send-Them-to-Splunk)
- [github]( https://github.com/mulesoft-catalyst/audit-log-aggregators)
- [mulesoft doc]( https://docs.mulesoft.com/jp/access-management/audit-logging)
#### æ©èœèŠä»¶ FRs vs éæ©èœèŠä»¶ NFRs
FR -> what äœãå®çŸããã
NFR -> how ã©ããã£ãŠå®çŸããã (reliability, availability, security ..)
- [User Story](https://www.atlassian.com/ja/agile/project-management/user-stories)
- [Epic, Stories]( https://www.atlassian.com/ja/agile/project-management/epics-stories-themes)
#### https://app.diagrams.net/ ãã¡ã€ã«ã®ã€ã³ããŒãæ¹æ³
1. https://app.diagrams.net/
2. File
3. Open From
4. Device
5. ããŠã³ããŒããã xml ãéžæ
- INT-SOL_ArchitectureDiagrams.drawio.xml
- APP-NET_ArchitectureDiagrams.drawio.xml
#### Architecture Document Template
https://knowledgehub.mulesoft.com/s/article/Anypoint-Platform-Architecture-Template
##### Q.ã¢ãŒããã¯ãã£ããã¥ã¡ã³ããã³ãã¬ãŒã ã¯å®éã«ã©ã®ããã«éçšãããŠããïŒ
- MuleSoft ã® Solution Atchitect ããŒã ãããããžã§ã¯ãã®åæèšèšãæ
åœããå Žåããã®ãã³ãã¬ãŒããããšã«ããã¥ã¡ã³ããçæããããšãããã
- ããŒãããŒäŒæ¥ãããã¥ã¡ã³ããçæããå Žåããã€ã MuleSoft ã® Solution Atchitect ããŒã ããããžã§ã¯ãã®åæã«åå ããå Žåãããã¥ã¡ã³ãã§äžè¶³ããŠããéšåãããã®ãã³ãã¬ãŒãã®å
容ãããšã«ææçã«ãµããŒãããå Žåãããã
ãããã®å Žåãããã®ããã¥ã¡ã³ããã³ãã¬ãŒãã¯åèãšããŠäœ¿ããããããã®ãŸãŸäœ¿çšãããšã¯éããªãã
â» API-led ã¢ãŒããã¯ãã£ã«ãã©ãŒã«ã¹ããããã¥ã¡ã³ã [Solution Design Template](https://knowledgehub.mulesoft.com/s/article/Solution-Design-Template) ããããŸãã
##### UML
- [UML](https://www.uml-diagrams.org/uml-25-diagrams.html)
- [Qiitaèšäº](https://qiita.com/taku_maru/items/80d39f2f043489033076)
### Module 2: :sparkles: Anypoint Platform ã³ã³ããŒãã³ããšæ©èœã®çè§£
[Anypoint Platform ãã¹ãã£ã³ã°ãªãã·ã§ã³ã®æ¯èŒ](https://docs.mulesoft.com/jp/general/intro-platform-hosting)
#### ã³ã³ãããŒã«ãã¬ãŒã³
- MuleSoft-hosted (anypoint.mulesoft.com) - US East
- MuleSoft-hosted (eu1.anypoint.mulesoft.com) - EU (Germany)
- [Anypoint Private Cloud Edition (PCE)](https://docs.mulesoft.com/jp/private-cloud/3.0/)
- [Goverment Cloud(US-only)](https://docs.mulesoft.com/jp/general/intro-platform-hosting)

Q. (from Seko san) Anypoint Private Cloud Editionãªã©ã®äŸå€çãªã³ã³ãããŒã«ãã¬ãŒã³ã䜿çšããå Žåã¯ãéåžžã®å¥çŽãšå¥ã®å¥çŽãå¿
èŠã ã£ããããŸããïŒ
- Platinum ãµãã¹ã¯ãªãã·ã§ã³ã+ Base ãµãã¹ã¯ãªãã·ã§ã³ +ããªã³ãã¬ãã¹ãããžã¡ã³ã +*ãããŒãžããµãŒãã¹ (å¿
é , è±èª)*
- å€ãã®å¶çŽãã: CloudHub, Runtime Fabric (Anypoint Security - Edge / Tokenization), Anypoint Design Center - Flow Designer, Secrets Manager, Anypoint Analytics, Object Store, Anypoint MQ etc..
- Anypoint Platform PCE 㯠Docker ããã³ Kubernetes ã䜿çšããŠçµã¿èŸŒã¿ã®é«å¯çšæ§ããã³æ¡åŒµæ§ãå®çŸããŸããDocker ã Kubernetes ã«ã€ããŠçè§£ããŠããªããŠããã©ãããã©ãŒã ãã€ã³ã¹ããŒã«ã§ããŸããããã©ãããã©ãŒã ã®ç®¡çããã³ãã©ãã«ã·ã¥ãŒãã£ã³ã°ãè¡ãã«ã¯ãããã®ä»çµã¿ãçè§£ããŠããå¿
èŠããããŸãã
#### ã©ã³ã¿ã€ã ãã¬ãŒã³
- **CloudHub (MuleSoft-hosted)**
- MuleSoft ã管çããAWSç°å¢
- CloudHub ã¯ãŒã«ãŒ = EC2 ã€ã³ã¹ã¿ã³ã¹
- ã¯ã©ãŠãããŒã¹ã® key-value ãã¢ã¹ãã¬ãŒãž: Object Store v2
- ã¯ã©ãŠãããŒã¹ã®æ°žç¶åVMãã¥ãŒ: Persistent Queue
- ã¹ã±ãŒãªã³ã°
- CHã¯ãŒã«ãŒã®æ°ãå¢ãã = ã¹ã±ãŒã«ã¢ãŠã
- CHã¯ãŒã«ãŒã®æ§èœãè¯ããã = ã¹ã±ãŒã«ã¢ãã
- ããŒããã©ã³ãµãŒ
- SLB(å
±æããŒããã©ã³ãµãŒ)
- HTTP 80 -> 8081
- HTTPS 443 -> 8082
- DLB(å°çšããŒããã©ã³ãµãŒ)
- HTTP 80 -> 8091
- HTTPS 443 -> 8092
- VPC ã«æ§æãã
- ã¹ã¿ã³ãã¢ããŒã³ Mule ã©ã³ã¿ã€ã
- ãªã³ãã¬ãã¹
- VM
- ãã©ã€ããŒãã¯ã©ãŠã (AWS, Azure, GCP..)
- Runtime Fabric (RTF)
- RTF-VM
- EC2 etc...
- RTF on self-managed k8s
- GKE, AKS, EKS etc...
#### Mule 4 Event
Mule Event
- Mule Message
- Attributes (屿§ãã¡ã¿ããŒã¿)
- Headers
- Query Params
- etc...
- **Payload (ããŒã¿ã®æ¬äœ)**
- Variables (vars)
- (error) ``<Object> ãšã©ãŒçºçæ``
- errorType ``<Object>`` >> HTTP:BAD_REQUEST
- namspace ``<String>``
- e.g HTTP
- identifier ``<String>``
- e.g. BAD_REQUEST
- description ``<String>``

#### API-led Connectivity (API äž»å°ã®æ¥ç¶æ§)
1. Experience API(EAPI)
- API ã¯ã©ã€ã¢ã³ãæ¯ã®éããåžåãã(ããŒã¿åããã©ãŒããã, ã»ãã¥ãªãã£..)
2. Process API(PAPI)
- ããžãã¹ããžãã¯
3. System API(SAPI)
- ããã¯ãšã³ãã®ããŒã¿ãååŸã»æŽæ°ã»äœæ
- çµ±äžã®ããŒã¿åãžã®å€æãè¡ãããšã(SAP Customer <-> SFDC Customer)
â»ããŒã¿åã®å€æã®è©±ã¯, Module 6 ã§ããå€ãè§ŠããŸã!
#### Spec-Driven Development
- ã©ã¡ãã®ããŒã«ãã©ã¡ãã®èšèªã§ãOKïŒ
- RAML 0.8/1.0
- OAS 2.0(a.k.a Swagger)/3.0
- ãªãïŒ
- ãã® API ã®åœ¹å²ãæ©èœã«ã€ããŠåæããšã
- ãã£ãŒãããã¯ãããã£ãŠæ¹åãã
- ããŒã¿åããšã³ããã€ã³ãåããã£ãŒã«ãåããã©ã¡ãŒã¿ (å¿
é or not)ããªã©ã«ã€ããŠã®äºå確èª
- 仿§éãã®ããªããŒã·ã§ã³ãèªåã§é©çš
- Studio ã«ã€ã³ããŒãããŠãåå°ãšãªãã¹ã±ã«ãã³ (ã€ã³ã¿ãã§ãŒã¹ãããŒ)ãèªåã§çæãã
- Exchange ã«å
¬éããã¿ã€ãã³ã°ã§
- API ããŒã¿ã«ãèªåçæããã
- 仿§ãããšã«ããã¥ã¡ã³ããèªåçæãããŸã
- API ã³ã³ãœãŒã«ãèªåçæããã
- ã¢ããã³ã°ãµãŒãã¹ãèªåçæããã (ãããã¿ã€ã)
- [ã·ãã¥ã¬ãŒã·ã§ã³ããããŒ](https://docs.mulesoft.com/jp/design-center/apid-behavioral-headers)æ©èœã§ãããå®éã«è¿ãã¢ãã¯åŒã³åºããå¯èœ(MS2-Delay etc..)
- ã³ãã¯ã¿ã®èªåçæ (REST Connect)
#### ã©ããªAPIãèšèšã»éçºãã!?
- :pushpin: COVID-19 API(ã³ãããŠã£ã«ã¹ API) **4**
- /variants(å€ç°æ ª)
- GET
- POST
- PUT
- /vaccines(ã¯ã¯ãã³)
- GET
- POST
- PUT
- /status(ææç¶æ³)
- /positiveCases(åäž)
- Weather API(å€©æ° API) 3
- Train Operation Info API(é»è»éè¡æ
å ±API) 3
- MLB API(ã¡ãžã£ãŒãªãŒã° API) 2
- Cafe API(ã«ãã§ API) 0
- Sauna API(ãµãŠã API) 0
#### RAML 仿§:
[github å°ã£ãããããã¿ãïŒ](https://github.com/raml-org/raml-spec/blob/master/versions/raml-10/raml-10.md/)
[Regex æ£èŠè¡šçŸ 101](https://regex101.com/)
```types:
EmailAddress:
type: string
pattern: ^.+@.+\..+$
minLength: 3
maxLength: 320
```
#### desctiption vs displayName
- desctiption
API 仿§ã®ããã¥ã¡ã³ãå
ã®èª¬ææžã(æ¥æ¬èªOK)
- displayName
API 仿§ã®ããã¥ã¡ã³ãã®èŠåºãããã³ãã¯ã¿ã®ãªãã¬ãŒã·ã§ã³ã«äœ¿çš (æ¥æ¬èªOK)
#### Semantic Versioning
Major version . Minor version . Patch version - https://semver.org/lang/ja/
2.2.**1** vs 2.2.**2**(ãã°ä¿®æ£)
1.**0**.0 vs 1.**1**.0(æ©èœè¿œå )
**2**.2.1 vs **3**.0.0(ãã¬ãŒãã³ã°ãã§ã³ãž ->ãåŸæ¹äºææ§ãä¿ãŠãªã倿Ž)
#### Basic Endpoint(åã蟌ã¿å)
+ã¢ããªã±ãŒã·ã§ã³ã®æ°ãæãããã
+vCoreã®æ¶è²»ãæãããã($$$)
+远å ã®ãããã¯ãŒã¯ãããããªã=远å ã®ã¬ã€ãã³ã·ãŒããªã
-Studio ã§ã®äœæ¥ãå¿
èŠ
-Mule ã¢ããªã±ãŒã·ã§ã³ããä¿è·ã§ããªã
#### Endpoint with Proxy(APIãããã·å)
+Non Mule ã¢ããªã±ãŒã·ã§ã³ã®ä¿è·
+Studio ã§ã®äœæ¥ãäžèŠ
+APIãããã·ãšAPIå®è£
ã®æç¢ºãªåé¢
+è€æ°ã®APIãããã·ã§ã1ã€ã®å®è£
ãä¿è·ããããšã«ãããã³ã³ã·ã¥ãŒããŒ/ã¯ã©ã€ã¢ã³ãããšã«é©çšããããªã·ãŒãå€ãã
-URLãè€æ°ãã=è€é
-ã¢ããªã±ãŒã·ã§ã³ã®æ°ãå¢ããŠããŸã
-vCoreãæ¶è²»ããŠããŸã($$$)
-ãããã¯ãŒã¯ã®ããããå¢ãã->ã¬ã€ãã³ã·ãŒã®å¢å (?)
#### [Service Mesh](https://docs.mulesoft.com/jp/service-mesh/1.1/)
[what is a service api](https://www.mulesoft.com/resources/api/what-is-a-service-mesh)

Q. from Seko san Service Mesh ã®ã³ã¢ã®æ¶è²»?

Yes, ã³ã¢ãæ¶è²»ããŸãã管çãã API ã®ãµã€ãºã«ãã£ãŠãã³ã¢ã®ãµã€ãºã¯å€ãããŸãã
[èªå®ããŒãããŒåãæ
å ±](https://mulesoftpartners.bloomfire.com/posts/3811857)
#### (WIP) [Flex Gatway](https://www.mulesoft.com/platform/api/flex-api-gateway)
-[video](https://share.vidyard.com/watch/Mr9r3ARNRHbgYrsBaTsBTo)
-[blog](https://blogs.mulesoft.com/news/introducing-universal-api-management-on-anypoint-platform/)
-[page](https://www.mulesoft.com/platform/api/flex-api-gateway)
#### AsyncAPI
[AsyncAPI](https://www.asyncapi.com/)
[blog](https://blogs.mulesoft.com/news/anypoint-platform/event-driven-architecture-asyncapi/)
#### Q. RAML ãã€ã³ããŒãããæã®ãšã©ãŒ: Ideue san error: Error while parsing API: Tooling instance could not be started, another attempt will be made

1.ããã·ã³ã¹ããã¯ã®ç¢ºèª (8GB RAM <, CPU 2.0 Ghz < )
2. Anypoint Studio ã®åèµ·å
#### Transform Message
```
%dw 2.0
output application/json
---
{"message": "hello world!"}
```
#### Anypoint Studio ã«ãã³ãã«ããã Mule ã©ã³ã¿ã€ã
MULE_HOME is set to /Applications/AnypointStudio.app/Contents/Eclipse/plugins/org.mule.tooling.server.4.4.0.ee_7.11.0.202201041751/mule
``/mule/apps``
- covid19-api (jar ãã¡ã€ã«ãå±éããããã®)
- covid19-api-anchor.txt
- åé€ãããš...
- Undeployed artifact 'covid19-api'
#### Flow vs Sub flow vs Private flow

#### Tanuki Wrapper ã®èšå®
/mule/conf/wrapper.conf


Q.MuleãšãŒãžã§ã³ããšã¯äœã§ããããïŒïŒåç§°ã¯èãèŠããããã®ã§ãããäœãæããŠããã®ãå¿ããŠããŸããŸããããïŒ
https://docs.mulesoft.com/mule-runtime/3.9/mule-agents
- Mule 3 ãŸã§äœ¿ãããŠãã agent
- Mule Runtime <-> Mule Management Console ã®ã³ãã¥ãã±ãŒã·ã§ã³(Mule Runtimes <-> Runtime Manager ã® agentã§ã¯ãªã)
- Mule Management Consoleã㯠End of Lifed on July 15, 2019.
- UI -> https://docs.mulesoft.com/mule-management-console/3.8/using-the-management-console-for-performance-tuning#debugging-process-details
- **Runtime Manage agent** https://docs.mulesoft.com/jp/runtime-manager/installing-and-configuring-runtime-manager-agent
NEW!: from Sekosan Q. HelloWorldèµ·åæã«çºçããWARNãã°(3ã€)ã¯ã©ããã£ããã®ã§ããããã
- CloudHubã§åãããããšã¯ãªãã®ãïŒãã°ç£èŠã§WARNãæŸãããšããããšæãã®ã§ïŒ
- HTTP Listner ãååšãããããŒãããã°ãCloudHubã§ãåãããŠããŸãããããã€å®äºæã«ãã忥ç¶(å³å¯ã«ã¯ãåã®æ¥ç¶)ãã®ã¡ãã»ãŒãžã衚瀺ããããããããã€å®äºæã®ãã®ã§ãªãããããã€åŸã«é »ç¹ã«åºåãããéã«ã¯ãã§ãã¯ããå¿
èŠãããå¯èœæ§ããããŸãã
- ãã®åœ±é¿ã§Studioãããããªæåãããããšã¯ãªãã®ã
- çŸç¶ãStudio ã®æåããããããªããšããããšã¯ç¢ºèªã§ããŠããŸããã
commit
https://github.com/mulesoft/mule/commit/3efbd8c723bec11d68c6c4468840ce36c2bbe1f5#diff-4d099ed2b3829aad281722289fc8c20fdfe74b914c673e07293b216dc2bdc2edR224
[onReconnectionSuccessful](https://github.com/mulesoft/mule/blob/3efbd8c723bec11d68c6c4468840ce36c2bbe1f5/modules/extensions-support/src/main/java/org/mule/runtime/module/extension/internal/runtime/source/ExtensionMessageSource.java#L374)
```
WARN 2022-02-01 09:39:59,406 [[MuleRuntime].uber.02: [covid19-api].uber@org.mule.runtime.module.extension.internal.runtime.source.ExtensionMessageSource.lambda$null$16:412 @ec0de3c] [processor: ; event: ] org.mule.runtime.module.extension.internal.runtime.source.ExtensionMessageSource: Message source 'listener' on flow 'covid-19-api-main' successfully reconnected
```
GET:/variants
```
%dw 2.0
output application/json
---
[{
"transmissibility": "4",
"name": "Omicron",
"incubationPeriod": 72,
"occupation": 90,
"detectedCounties": [
"ZA"
],
"originCountry": "ZA"
}]
```
POST:/variants
```
%dw 2.0
output application/json
---
{
"message": "Data has been successfully created"
}
```
## Day 2
### Module 3: :sparkles: Mule ã¢ããªã±ãŒã·ã§ã³ã䜿çšããã€ã³ãã°ã¬ãŒã·ã§ã³ãœãªã¥ãŒã·ã§ã³ã®èšèš
#### ãããŒã®åŠç
å·Šããå³ãž(ã³ãŒãã®äžããäžãž) **åæç**ã«åŠçãè¡ã
#### éåæã®åŠçãè¡ãããã»ããµã»ã¹ã³ãŒãã»ã³ãã¯ã¿ã®äŸ
- Async ã¹ã³ãŒã
- Scatter-Gatherãã«ãŒã¿ãŒ
- VM ã³ãã¯ã¿
- JMS ã³ãã¯ã¿
- Logger -> ããã©ã«ã㯠Async Logger
- Batch Job
- Parrarel For Each
- etc..
#### Mule SDK > ã³ãã¯ã¿ã»ã¢ãžã¥ãŒã«ã®éçº
https://docs.mulesoft.com/jp/mule-sdk/1.1/
- Java SDK
- XML SDK (RAML ã OAS ããã³ãã¯ã¿ãèªåçæãããREST Connect ã«ã䜿çšããã)
#### How to set up slack connector
https://www.youtube.com/watch?v=FNDDfsT152M
#### ãã©ãã«ãŒã·ã¥ãŒãã£ã³ã°: Anypoint Studio ãã Anypint Platform ãžãã°ã€ã³ãã§ããªãæã®å¯ŸåŠæ¹æ³( 7.11.0-)
https://help.mulesoft.com/s/article/Anypoint-Studio-Not-Storing-Anypoint-Platform-Credentials
Window (Anypoint Platform) > Preferences > Secure Storage ãæ€çŽ¢ > Contents ã¿ã>[Default Secure Storage] > Anypoint Studio > Anypoint Platform ã®èªèšŒæ
å ±ãDelete
#### CloudHub 0.X vCore?
https://docs.mulesoft.com/jp/runtime-manager/cloudhub-architecture#cloudhub-%E3%83%AF%E3%83%BC%E3%82%AB%E3%83%BC
https://blogs.mulesoft.com/dev-guides/how-to-tutorials/cloudhub-vs-runtime-fabric-for-high-performing-mules/
#### Q.Gitãšã®é£æº?
https://developer.mulesoft.com/tutorials-and-howtos/quick-start/how-to-setup-git-anypoint-studio-egit-plugin
- åºæ¬ãã®èšäºã®éãã§é£æºå¯èœ (egit ãã©ã°ã€ã³)ã
- ãSCM ã§ïŒæ®µéèªèšŒãæå¹ã«ããŠããå Žåã¯ã"unauhtorized" ãšã©ãŒãåºãå¯èœæ§ãããããã¹ã¯ãŒãã®ä»£ããã«[ã¢ã¯ã»ã¹ããŒã¯ã³](https://docs.github.com/ja/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token)ã䜿çšããããšã§åé¿å¯èœã
ã
#### Mule 3 -> Mule 4
- https://docs.mulesoft.com/jp/mule-runtime/4.4/migration-intro
- https://docs.mulesoft.com/jp/mule-runtime/4.4/migration-cheat-sheet
#### Scheduler ã®æå
maxConcurrency: CloudHub ã§ã¯ "1"
- CloudHub
- è€æ°ã®ã¯ãŒã«ãŒããã£ãŠããã©ã¡ããã®ã¯ãŒã«ãŒã§å®è¡
- Cron 㯠UTC ã®ã¿ã€ã ãŸãŒã³ã䜿çšãã
- ã¹ã¿ã³ãã¢ããŒã³ & RTF
- Clusteræ§æããšã£ãŠããªãå Žå
- ããããã®ããŒãã§ Scheduler ãå®è¡
- Clusteræ§æããšã£ãŠããå Žå
- 1ã€ã®ããŒãã§å®è¡ããã (= primary ããŒã)
#### DataWeave
- [Playground Library](https://developer.mulesoft.com/learn/dataweave/)
#### Error Handler ã®ã¹ã³ãŒã
https://docs.mulesoft.com/jp/mule-runtime/4.4/error-handling
0. **Mule**ããã©ã«ããšã©ãŒãã³ãã©ãŒ
- ã«ã¹ã¿ãã€ãºãªã©ã¯äžå¯
- æ±çšçã«åŠç (Propagate)
1. Application/Global
- åå¥ã®ãšã©ãŒãã³ãã©ãŒ(2.Flow, 3.Try/Proccessor)ãèšå®ãããŠããªããšãã ãããã®ãã³ãã©ãŒã§åŠçãããã
- Global Elements > Create > Configuration > Default Error Handler ã§èšå®
**Default** ã¯ãã¢ããªã±ãŒã·ã§ã³ã®ããã©ã«ã(=Application/Global Error Handler)ã®æå³ã§ãããã0.Mule ããã©ã«ããšã©ãŒãã³ãã©ãŒãã®ããšã§ã¯ãªã
2. Flow
3. Try/Processor
#### Error Handler ã®çš®é¡
1. On Error Propagate
- ããã©ã«ãã®åŠç(**Mule**ããã©ã«ããšã©ãŒãã³ãã©ã§äœ¿çš)
- "ãšã©ãŒããšã©ãŒ"ãšããŠåŠç
- ãšã©ãŒãªããžã§ã¯ããäŒæããŠãåŒã³åºãå
ã«äŒãã
2. On Error Continue
- ãŸãã§"ãšã©ãŒãèµ·ããŠããªããã®ããã«"åŠç
- èªåã®ãšã©ãŒãä»ã®åŠçã«åœ±é¿ããªãããã«ã"ãšã©ãŒã飲ã¿èŸŒã"
#### ã«ãŒã¿ãŒ
- Choice
- if, else-if, else...
- Scatter-Gather
- éåæ,ãã«ãã¹ã¬ããã§ãã¹ãŠã®ã«ãŒãã®åŠçãè¡ã
- ãã©ã³ã¶ã¯ã·ã§ã³åŠçã¯äŸå€
- MULE:COMPOSITE_ERROR ãã¹ããŒ
- ãªããžã§ã¯ãããªã¿ãŒã³ããã
```
{
"payload" : {
"0" : {
"attributes" : {
"properties" : { ⊠}
"headers" : { ⊠}
âŠ
},
"payload" : {
"firstRoute" : "First Payload"
}
}
"1" : {
âŠ
"payload" : {
"secondRoute" : "Second Payload"
}
}
âŠ
}
```
- First Succesful
- äžããé çªã«å®è¡ > ããããã®ã«ãŒãã§åŠçã«æåãããå®äº
- 1(倱æ)> 2(æå)> ~~3(åŠçãããªã)~~
- Round Robin
- é çªã«å®è¡
- 1 > 2 > 3 > 1 > 2 > 3 > 1 ....
##### ã«ãŒã¿ãŒãšã¯ãµãµã€ãº!
- 2 çªç®ã® API ããæåã® API ã®ã¬ã¹ãã³ã¹ãå¿
èŠãšãã (... HTTP Request 1 -> HTTP Request 2-> ...)
- A. **ã«ãŒã¿ãŒã䜿çšããªã**!
- A. vars (倿°)ã« HTTP Request 1ã®çµæãå
¥ããŠããããšã§ãpayload ãäžæžãããªã (ãããã¯ã HTTP Request 2ã®çµæã target variable ã«ä¿åããããšã§ãHTTP Request 1ã®payload ãäžæžãããªã)
- åAPIã¯ããããã®ã¬ã¹ãã³ã¹ (泚æã顧客) ã«äŸåããªãããçµæãçµ±åããå¿
èŠããã
- A. **Scatter-Gather**
- 2 ã€ã® Address Validation (äœæããªããŒã·ã§ã³) API ãšã³ããã€ã³ãã§åäžã®æ©èœãå®è¡ãããããã®ãã¡ã®1ã€ã¯ãã©ãŒã«ããã¯ãªãã·ã§ã³ã«ãªã
- A. **First Successful**
- ãªãŒãžã§ã³ã«å¿ã㊠Inventory (åšåº«) API ã®ç°ãªããªãŒãžã§ã³ãšã³ããã€ã³ã(ANZ, Japan) ã䜿çšããå¿
èŠããã
- A. **Choice**
- åçš®ä¿éºäŒç€Ÿããã® Insurance Quote (ä¿éºã®èŠç©ãã) API ãåŒã³åºããçµæãçµ±åããŠãœãŒãããå¿
èŠããã
- A. **Scatter-Gather** -> **Dataweave**
### Module 4: é©å㪠Mule 4 ã€ãã³ãåŠçã¢ãã«ã®éžæ
#### Mule 4 - 3ã€ã®ã€ãã³ãå®è¡ã»åŠçã®ã¿ã€ã
- CPU_LITE
- CPU_INTENSIVE
- ãã®çš®ã®åŠçã¯èªåçã«ã¯äºæž¬ã§ããªã
- IO_INTENSIVE
```
@Execution(CPU_INTENSIVE)
public void computeFlightPlan() {
...
}
```
##### DEDICATED: Mule 4.1, 4.2
3ã€ã®å®è¡ã¢ãã«ããšã«ãå¥ã
ã®ã¹ã¬ããããŒã«ãçšæãããŠããã(CPU_LITE, CPU_INTENSIVE, **IO_INTENSIVE**)
scheduler-pool.conf
IO_INTENSIVE
```
# The maximum number of threads to allow in the I/O pool.
# Supports Expressions
# Only applies when org.mule.runtime.scheduler.threadPool.strategy=DEDICATED
#org.mule.runtime.scheduler.io.threadPool.maxSize=max(2, cores + ((mem - 245760) / 5120))
```
CPU_INTENSIVE
```
# The number of threads to keep in the cpu_intensive pool, even if they are idle.
# Supports Expressions
# Only applies when org.mule.runtime.scheduler.threadPool.strategy=DEDICATED
#org.mule.runtime.scheduler.cpuIntensive.threadPool.size=2*cores
```
CPU_LITE
```
# The number of threads to keep in the cpu_lite pool, even if they are idle.
# Supports Expressions
# Only applies when org.mule.runtime.scheduler.threadPool.strategy=DEDICATED
#org.mule.runtime.scheduler.cpuLight.threadPool.size=2*cores
```
##### UBER ã¹ã¬ããããŒã«: Mule 4.3 <
scheduler-pool.conf
UBER ã¹ã¬ããããŒã«
```
# The maximum number of threads to allow in the uber pool.
# Supports Expressions
# Only applies when org.mule.runtime.scheduler.threadPool.strategy=UBER
org.mule.runtime.scheduler.uber.threadPool.maxSize=max(2, cores + ((mem - 245760) / 5120))
```
## Day 3
### SOAP vs REST(ful)
- SOAP (Simple(?) Object Access Protocol)
- XML
- WSDL
- REST(ful)
- **JSON**/XML
- RAML, OAS
Q. RAMLãæŽæ°ããŠãã€ã³ã¿ãŒãã§ãŒã¹ãããŒãå床 scaffolding ãããšãã®ã·ããªãª?
- ã·ããªãª1: RAMLã«æ°ãããªãœãŒã¹ãã¡ãœããã远å ãããšã
- æ°ããã€ã³ã¿ãŒãã§ãŒã¹ãããŒã远å ããã
- æ¢åã®ã€ã³ã¿ãŒãã§ãŒã¹ãããŒã«ã¯å€æŽãå
¥ããªã
- ã·ããªãª2: æ¢åã®ãªãœãŒã¹ã®æ¢åã®ãªãœãŒã¹&ã¡ãœããã«å€æŽãå ããå Žå
- æ¢åã®ã€ã³ã¿ãŒãã§ãŒã¹ãããŒã«ã¯å€æŽãå
¥ããªã
- ã·ããªãª3: æ¢åã®ãªãœãŒã¹ã®æ¢åã®ãªãœãŒã¹&ã¡ãœããã«å€æŽãå ãã && **察象ã®ã€ã³ã¿ãŒãã§ãŒã¹ãããŒãXML ããåé€ããå Žå** OR XMLèªäœãåé€ããå Žå
- ææ°ã®RAMLã«åºã¥ããŠãã€ã³ã¿ãŒãã§ãŒã¹ãããŒãçæããã
version 1.0.1

èµ€ç·ã®ã€ã³ã¿ãŒãã§ãŒã¹ãåé€åŸ, version 1.0.2 ã scaffold ãããšææ°ã®ãããŒã«å€æŽãããã

#### Hybrid ç°å¢ã®æ§ç¯(Runtime Manager agent)
- node1
1. Runtime manager > add server > server åãæå®ããŠãã³ãã³ããååŸ(**node1**)
2. serverãšããŠç»é²ãã Mule ã©ã³ã¿ã€ã ã®binã§amc_setupã³ãã³ããå®è¡ (windowsã§ã¯"./"ãåé€)
3. Hybridã§ã®ã©ã³ã¿ã€ã ã®ç®¡çã»ç£èŠãå¯èœã«ãªã
4. ./mule or mule.bat ã§ã©ã³ã¿ã€ã ãå®è¡
5. /apps/mod03-scheduler-app.jar ãå±é
- node2
1. Runtime manager > add server > server åãæå®ããŠãã³ãã³ããååŸ(**node2**)
2. serverãšããŠç»é²ãã Mule ã©ã³ã¿ã€ã ã®binã§amc_setupã³ãã³ããå®è¡ (windowsã§ã¯"./"ãåé€)
3. Hybridã§ã®ã©ã³ã¿ã€ã ã®ç®¡çã»ç£èŠãå¯èœã«ãªã
4. ./mule or mule.bat ã§ã©ã³ã¿ã€ã ãå®è¡
5. /apps/mod03-scheduler-app.jar ãå±é
NEW!: WARN (ã¹ã¿ã³ãã¢ããŒã³ Mule + RT Agent )
```
WARN 2022-02-02 10:31:34,815 [WebSocketInboundExecutor] [processor: ; event: ] com.mulesoft.agent.external.handlers.administration.ComponentRequestHandler: Ignored reference in configuration: 'enabled' does not allow dynamic configuration for component 'mule.agent.tracking.handler.analytics'
```
- **mule.agent.tracking.handler.analytics.enable** ã®èšå®ããtrueãã«ã倿Žããããšã§ WARN ã¡ãã»ãŒãžã¯ãªããªãããã®èšå®ã¯ããRuntime Manager ããããŒã®ã¹ããŒã¿ã¹ããã©ãããã©ãŒã åŽã«éä¿¡ããã®ãæå¹ã«ããããã«äœ¿çšããã
```

```
Hi All, is it possible to disable runtime agent from reporting the flow statuses back to the platform?
6 replies
Pablo Rodriguez
2 years ago
yes, if you put this in the mule-agent.yaml:
internalHandlers:
flow.status.notification.internal.message.handler:
enabled: false
#### ã¬ã³ãŒã
- For Each
- ã·ã³ã°ã«ã¹ã¬ãã
- åæåŠç
- ããã©ã«ã batch size = 1
- [1, 2, 3].. > 1 > 2 > 3..
- batch size = 2
- [1, 2, 3].. > **1,2** > 3..
- For Each ã¹ã³ãŒãã®äžã§ payload ã倿ŽããŠããMule Event ã® payloadã«åœ±é¿ã¯ãªã
```
INFO 2022-02-02 13:34:45,079 [[MuleRuntime].uber.13: [mod04-foreach_pararrelforeach_batchjob].forEach.CPU_LITE @cc46f1] [processor: forEach/processors/2/processors/0; event: 72531310-83e1-11ec-91c7-0028f8083c74] org.mule.runtime.core.internal.processor.LoggerMessageProcessor: 1
INFO 2022-02-02 13:34:45,091 [[MuleRuntime].uber.13: [mod04-foreach_pararrelforeach_batchjob].forEach.CPU_LITE @cc46f1] [processor: forEach/processors/2/processors/0; event: 72531310-83e1-11ec-91c7-0028f8083c74] org.mule.runtime.core.internal.processor.LoggerMessageProcessor: 2
INFO 2022-02-02 13:34:45,097 [[MuleRuntime].uber.13: [mod04-foreach_pararrelforeach_batchjob].forEach.CPU_LITE @cc46f1] [processor: forEach/processors/2/processors/0; event: 72531310-83e1-11ec-91c7-0028f8083c74] org.mule.runtime.core.internal.processor.LoggerMessageProcessor: 3
INFO 2022-02-02 13:34:45,108 [[MuleRuntime].uber.13: [mod04-foreach_pararrelforeach_batchjob].forEach.CPU_LITE @cc46f1] [processor: forEach/processors/2/processors/0; event: 72531310-83e1-11ec-91c7-0028f8083c74] org.mule.runtime.core.internal.processor.LoggerMessageProcessor: 4
INFO 2022-02-02 13:34:45,116 [[MuleRuntime].uber.13: [mod04-foreach_pararrelforeach_batchjob].forEach.CPU_LITE @cc46f1] [processor: forEach/processors/2/processors/0; event: 72531310-83e1-11ec-91c7-0028f8083c74] org.mule.runtime.core.internal.processor.LoggerMessageProcessor: 5
INFO 2022-02-02 13:34:45,122 [[MuleRuntime].uber.13: [mod04-foreach_pararrelforeach_batchjob].forEach.CPU_LITE @cc46f1] [processor: forEach/processors/2/processors/0; event: 72531310-83e1-11ec-91c7-0028f8083c74] org.mule.runtime.core.internal.processor.LoggerMessageProcessor: 6
INFO 2022-02-02 13:34:45,130 [[MuleRuntime].uber.13: [mod04-foreach_pararrelforeach_batchjob].forEach.CPU_LITE @cc46f1] [processor: forEach/processors/2/processors/0; event: 72531310-83e1-11ec-91c7-0028f8083c74] org.mule.runtime.core.internal.processor.LoggerMessageProcessor: 7
INFO 2022-02-02 13:34:45,141 [[MuleRuntime].uber.13: [mod04-foreach_pararrelforeach_batchjob].forEach.CPU_LITE @cc46f1] [processor: forEach/processors/2/processors/0; event: 72531310-83e1-11ec-91c7-0028f8083c74] org.mule.runtime.core.internal.processor.LoggerMessageProcessor: 8
INFO 2022-02-02 13:34:45,151 [[MuleRuntime].uber.13: [mod04-foreach_pararrelforeach_batchjob].forEach.CPU_LITE @cc46f1] [processor: forEach/processors/2/processors/0; event: 72531310-83e1-11ec-91c7-0028f8083c74] org.mule.runtime.core.internal.processor.LoggerMessageProcessor: 9
INFO 2022-02-02 13:34:45,157 [[MuleRuntime].uber.13: [mod04-foreach_pararrelforeach_batchjob].forEach.CPU_LITE @cc46f1] [processor: forEach/processors/2/processors/0; event: 72531310-83e1-11ec-91c7-0028f8083c74] org.mule.runtime.core.internal.processor.LoggerMessageProcessor: 10
```
- Prarrel For Each
- ãã«ãã¹ã¬ãã
- éåæåŠç
- åã¬ã³ãŒãã®å€ã倿Žå¯èœ
```
INFO 2022-02-02 13:33:57,974 [[MuleRuntime].uber.06: [mod04-foreach_pararrelforeach_batchjob].parrarelForEach.CPU_LITE @1e52b5e4] [processor: parrarelForEach/processors/2/processors/0; event: 55d97e40-83e1-11ec-91c7-0028f8083c74] org.mule.runtime.core.internal.processor.LoggerMessageProcessor: 2
INFO 2022-02-02 13:33:57,974 [[MuleRuntime].uber.09: [mod04-foreach_pararrelforeach_batchjob].parrarelForEach.CPU_LITE @1e52b5e4] [processor: parrarelForEach/processors/2/processors/0; event: 55d97e40-83e1-11ec-91c7-0028f8083c74] org.mule.runtime.core.internal.processor.LoggerMessageProcessor: 5
INFO 2022-02-02 13:33:57,974 [[MuleRuntime].uber.08: [mod04-foreach_pararrelforeach_batchjob].parrarelForEach.CPU_LITE @1e52b5e4] [processor: parrarelForEach/processors/2/processors/0; event: 55d97e40-83e1-11ec-91c7-0028f8083c74] org.mule.runtime.core.internal.processor.LoggerMessageProcessor: 4
INFO 2022-02-02 13:33:57,975 [[MuleRuntime].uber.01: [mod04-foreach_pararrelforeach_batchjob].parrarelForEach.CPU_LITE @1e52b5e4] [processor: parrarelForEach/processors/2/processors/0; event: 55d97e40-83e1-11ec-91c7-0028f8083c74] org.mule.runtime.core.internal.processor.LoggerMessageProcessor: 1
INFO 2022-02-02 13:33:57,980 [[MuleRuntime].uber.07: [mod04-foreach_pararrelforeach_batchjob].parrarelForEach.CPU_LITE @1e52b5e4] [processor: parrarelForEach/processors/2/processors/0; event: 55d97e40-83e1-11ec-91c7-0028f8083c74] org.mule.runtime.core.internal.processor.LoggerMessageProcessor: 3
INFO 2022-02-02 13:33:57,984 [[MuleRuntime].uber.10: [mod04-foreach_pararrelforeach_batchjob].parrarelForEach.CPU_LITE @1e52b5e4] [processor: parrarelForEach/processors/2/processors/0; event: 55d97e40-83e1-11ec-91c7-0028f8083c74] org.mule.runtime.core.internal.processor.LoggerMessageProcessor: 6
INFO 2022-02-02 13:33:58,001 [[MuleRuntime].uber.11: [mod04-foreach_pararrelforeach_batchjob].parrarelForEach.CPU_LITE @1e52b5e4] [processor: parrarelForEach/processors/2/processors/0; event: 55d97e40-83e1-11ec-91c7-0028f8083c74] org.mule.runtime.core.internal.processor.LoggerMessageProcessor: 7
INFO 2022-02-02 13:33:58,005 [[MuleRuntime].uber.12: [mod04-foreach_pararrelforeach_batchjob].parrarelForEach.CPU_LITE @1e52b5e4] [processor: parrarelForEach/processors/2/processors/0; event: 55d97e40-83e1-11ec-91c7-0028f8083c74] org.mule.runtime.core.internal.processor.LoggerMessageProcessor: 8
INFO 2022-02-02 13:33:58,007 [[MuleRuntime].uber.13: [mod04-foreach_pararrelforeach_batchjob].parrarelForEach.CPU_LITE @1e52b5e4] [processor: parrarelForEach/processors/2/processors/0; event: 55d97e40-83e1-11ec-91c7-0028f8083c74] org.mule.runtime.core.internal.processor.LoggerMessageProcessor: 9
INFO 2022-02-02 13:33:58,008 [[MuleRuntime].uber.14: [mod04-foreach_pararrelforeach_batchjob].parrarelForEach.CPU_LITE @1e52b5e4] [processor: parrarelForEach/processors/2/processors/0; event: 55d97e40-83e1-11ec-91c7-0028f8083c74] org.mule.runtime.core.internal.processor.LoggerMessageProcessor: 10
```
- Batch Job
- ãã«ãã¹ã¬ãã
- éåæåŠç
- pararell (䞊åã«) åŠçãè¡ã
- 倿°ã¯ãåã¬ã³ãŒãã«åºæã®ãã®
- ã¬ã³ãŒã1 vars.hoge = true (ã¬ã³ãŒã1 ã® vars.hoge ã¯ããã®ãŸãŸ BatchStep A, B, C ã§åç
§ã»å€æŽå¯èœ
- ã¬ã³ãŒã2 vars.hoge = falseã(ã¬ã³ãŒã2 ã® vars.hoge ã¯ããã®ãŸãŸ BatchStep A, B, C ã§åç
§ã»å€æŽå¯èœ)
â»ãããã®å€æ°ã¯ãå Batch Step ãè¶
ããŠåç
§ã»å€æŽãã§ãã
â»Batch Job ã¹ã³ãŒãã®å®äºåŸã¯ãå倿°ãåç
§ããããšã¯ã§ããªã
- Batch Step
- Batch Job ã®åŠçã®ã¹ã³ãŒã
- ããããã® Step ã¯ãããããã®æ¡ä»¶ã«åºã¥ããŠãã¬ã³ãŒããåãå
¥ãã (acceptPolicy, acceptExpression)
- e.g. acceptExpression: ```#[vars.hogeFlag==true]```
acceptPolicy: ONLY_FAILURES (åŠçã«å€±æããã¬ã³ãŒãã ããåŠçãã Batch Step)
- Batch Aggregator
- Bulk Insert ãªã©ããŸãšããŠåŠçãè¡ã
- 2çš®é¡ã®èšå®
1. Fixed Size (åºæã®ãµã€ãº)
2. Streaming
- maxFailedRecords
- 倱æããã¬ã³ãŒãã蚱容ããæ° (ããã©ã«ã 0)
- batchBlockSize
- åã¹ã¬ãããã©ã®ãããã®åäœã§ãåã¬ã³ãŒãããŸãšããŠåŠçããã (ããã©ã«ã100)
e.g. 1000 ã¬ã³ãŒã
1-100(100åäœ)
101-200(100åäœ)
201-300(100åäœ)
...
901-1000(100åäœ)
- onComplete ãã§ãŒãºã§ã® payload
ãµããªãŒã¬ããŒã
```
{
"onCompletePhaseException": null,
"loadingPhaseException": null,
"totalRecords": 2000,
"elapsedTimeInMillis": 8909,
"failedOnCompletePhase": false,
"failedRecords": 1,
"loadedRecords": 2000,
"failedOnInputPhase": false,
"successfulRecords": 1999,
"inputPhaseException": null,
"processedRecords": 2000,
"failedOnLoadingPhase": false,
"batchJobInstanceId": "9d6a7e50-5bd0-11ec-8902-a483e7ab0cd9"
}
```
## ãšã¯ãµãµã€ãº! ããŒã¿ã®åŠç
- MySQL ããŒã¿ããŒã¹ã SaaS CRM ã·ã¹ãã ãšåæãããå¿
èŠããã
- CRM ã·ã¹ãã ã¯ã§ããã ãæ©ãæŽæ°ããªããã°ãªããªã
- ãã®ã€ã³ãã°ã¬ãŒã·ã§ã³ã§ã¯ãåã¬ã³ãŒãã®ç£æ»ãšè¿œè·¡ããµããŒãããå¿
èŠããã
- 倱æããã¬ã³ãŒãã®åŸåŠçãè¡ããããã«ã人ãæäœã§ããããã«ããŠããå¿
èŠããã
- Mule ã¢ããªã±ãŒã·ã§ã³ã¯ãåäžã® 0.2 vCore CloudHub ã¯ãŒã«ãŒãžã®ãããã€ãæ³å®ããŠèšèšãããŠãã (1 GB ã®ããŒãã¡ã¢ãªïŒ
1. On Table Row -> 1è¡ãã€ããŒã¿ãåŠçãã
- TODO
- TODO
2. Scheduler + DB Select + BatchJob -> è€æ°è¡ãäžæ°ã«ã»ã¬ã¯ã
- TODO
- TODO
- TODO
## ãšã¯ãµãµã€ãº 4-3ïŒäžæ¹å (one-way) ã®ãã¡ã€ã«è»¢éãŠãŒã¹ã±ãŒã¹ã«é©ãã Mule ã€ãã³ãåŠçãèšèšãã
- 1æ¥ã«äœåãã©ã³ãã ã«ã顧客ã®è²¡åããŒã¿ãå«ãŸããæ°ãããœãŒã¹ãã¡ã€ã«ãããã¡ã€ã«ãµãŒããŒäžã®ç¹å®ã®ãã£ã¬ã¯ããªã«ã¢ããããŒããã
- Mule ã¢ããªã±ãŒã·ã§ã³ã¯ããã«ãã¡ã€ã«ãåŠçããã¿ãŒã²ããã® MySQL ããŒã¿ããŒã¹ã«çµæãéä¿¡ããå¿
èŠããã
- åãã¡ã€ã«ã«çŽ100äžä»¶ã®é¡§å®¢ããŒã¿ã¬ã³ãŒããå«ãŸããŠãã
- åã¬ã³ãŒãã®ç£æ»ãšè¿œè·¡æ©èœãäžå¯æ¬
- 倱æããã¬ã³ãŒãã®åŸåŠçãè¡ããããã«ã人ãæäœã§ããããã«ããŠããå¿
èŠããã
- Mule ã¢ããªã±ãŒã·ã§ã³ã¯ åäžã® 0.2 vCore CloudHubã¯ãŒã«ãŒãžã®ãããã€ãæ³å®ããŠèšèšãããŠãã(1 GBã®ããŒãã¡ã¢ãªãŒ)
1. TODO
2. TODO
3. TODO
4. TODO
Q. On Table Row ãŠã©ãŒã¿ãŒããŒã¯ã«ã©ã ã§ã¯æ¥ä»äœ¿ããã?
https://github.com/mulesoft/mule-db-connector/blob/master/src/main/java/org/mule/extension/db/internal/source/RowListener.java#L189
Q.ãã«ãã¹ã¬ããã®ã¹ããªãŒãã³ã°åŠçããã¥ã¡ã³ã?
- Mule 3 ã®ã¹ããªãŒã åŠçã®èª²é¡
課é¡1. ããŒã¿ã¹ããªãŒã 㯠1 åããã³ã³ã·ã¥ãŒã ã§ããªã
> 次ã®äŸã¯ããã¡ã€ã«ã«æžãèŸŒãæ¬æ (ãã€ããŒã) ãæã€ POST ã¡ãœãããåãåã HTTP Listener ãœãŒã¹ã®ãããŒã瀺ããŠããŸãããã®ãããŒã«ãããæåã®ãã¡ã€ã«ã¯æ£ããæžã蟌ãŸããŸããã2 ã€ç®ã®ãã¡ã€ã«ã¯ã³ã³ãã³ãã空ã«ãªããŸããããã¯ãã¹ããªãŒã ãã³ã³ã·ã¥ãŒã ããåã³ã³ããŒãã³ãããæ°ããã¹ããªãŒã ãåä¿¡ããããšãäºæããŠããããã§ããæåã® File Write æäœãã¹ããªãŒã ãã³ã³ã·ã¥ãŒã ãããšã2 ã€ç®ã® File Write æäœã¯ç©ºã®ã¹ããªãŒã ãåãåããŸãããã®ããã2ã€ç®ã®æäœã¯ãã¡ã€ã«ã«æžã蟌ãã³ã³ãã³ããæã¡ãŸããã
>

課é¡2. Transform Message + Logger
> 次ã®äŸã§ãDataWeave 倿ã®åŸã§ãã€ããŒãããã°ã«èšé²ããããšãããšãåããããªçµæ(空ã®ã¹ããªãŒã )ãšãªããŸããHTTP Listener ã, payload ã¹ããªãŒã ãåãåããã¹ããªãŒã ã Transform Message ã³ã³ããŒãã³ãã«éããæç¹ã§ã¯ãŸã ã¡ã¢ãªã«æ®ã£ãŠãããããã³ã³ããŒãã³ãã¯ã¹ããªãŒã ãã³ã³ã·ã¥ãŒã ããŸããTransform Message ã³ã³ããŒãã³ãã§ã³ã³ãã³ããã³ã³ã·ã¥ãŒã ããåŸã§ã2 ã€ç®ã® Logger ã¯ç©ºã®ã¹ããªãŒã ãåä¿¡ããŸã

課é¡ïŒ. ããŒã¿ã¹ããªãŒã ãåæã«ã³ã³ã·ã¥ãŒã ããããšã¯ã§ããŸããã
> 次ã®äŸã¯ãScatter-Gather ã«ãŒã¿ã䜿çšããŠããŒã¿ã¹ããªãŒã ãåå²ãããã€ããŒãã®ãã°ãžã®èšé²ãšãã¡ã€ã«ãžã®æžã蟌ã¿ãåæã«å®è¡ãããããŒã瀺ããŠããŸããç°ãªãããã»ããµãã§ãŒã³ã§ããŒã¿ã¹ããªãŒã ã®ã³ã³ãã³ããåæã«åŠçããããšã¯ã§ããªããããã¢ããªã±ãŒã·ã§ã³ã¯ã¹ããªãŒã ã®äžéšããã¡ã€ã«ã§åãåããæ®ãããã°ã§åãåããŸãã
https://docs.mulesoft.com/jp/mule-runtime/4.4/streaming-about

#### Mule4 ã®ããã©ã«ã - repeatable stream
> Mule 4 ã§ã¯ãã¹ããªãŒã ãåŠçããããã®ããã©ã«ããã¬ãŒã ã¯ãŒã¯ãšããŠå埩å¯èœã¹ããªãŒã ã远å ãããŠããŸããå埩å¯èœã¹ããªãŒã ã䜿çšãããšãæ¬¡ã®æäœãå®è¡ã§ããŸãã
- ã¹ããªãŒã ãè€æ°åèªã¿èŸŒãããšãã§ããŸãã
- ã¹ããªãŒã ã«åæã«ã¢ã¯ã»ã¹ã§ããŸãã
> ã³ã³ããŒãã³ããã¹ããªãŒã ãã³ã³ã·ã¥ãŒã ãããšãMule ã¯ãã®ã³ã³ãã³ããäžæãããã¡ã«æ ŒçŽããŸãã以åŸãã©ã³ã¿ã€ã ã¯ã¹ããªãŒã ã®ã³ã³ãã³ãããã³ãã©ãªãããã¡ããã³ã³ããŒãã³ãã«äŸçµŠããããšã§ããã§ã«ã¹ããªãŒã ãä»ã®ã³ã³ããŒãã³ãã«ãã£ãŠäœåºŠã³ã³ã·ã¥ãŒã ãããŠããããšããåã³ã³ããŒãã³ããå®å
šãªã¹ããªãŒã ãåä¿¡ã§ããããã«ããŸãããã®åŠçã¯èªåçã«è¡ãããããããŠãŒã¶ãç¹å¥ãªèšå®ãããå¿
èŠã¯ãªããåã³ã¢ã¯ã»ã¹ããããã«ã¹ããªãŒã ãå¥ã®å Žæã«ä¿åããããã®åé¿çãèããå¿
èŠã¯ãããŸããããã®èšå®ã«ãããäžèšã®3ã€ã®èª²é¡ã®ãã¡ã課é¡1ãšèª²é¡2ã解決ãããŸãã
> ãã¹ãŠã®å埩å¯èœã¹ããªãŒã ã¯äžŠåã¢ã¯ã»ã¹ããµããŒãããŠããŸããã€ãŸããåã³ã³ããŒãã³ããç°ãªãã¹ã¬ããã§å®è¡ãããŠãããšãã«ã2ã€ã®ã³ã³ããŒãã³ããåãã¹ããªãŒã ãèªã¿åãããšããŠãå¿é
ããå¿
èŠã¯ãããŸãããMule ã«ãããã³ã³ããŒãã³ããã¹ããªãŒã ãèªã¿åã£ãŠãã³ã³ããŒãã³ãBã«å¯ŸããŠäžåã®å¯äœçšãçºçãããªãããšãèªåçã«ç¢ºèªãããŸããããã«ãã課é¡3ã解決ãããŸãã
- ãããåŠçã¯ã¡ã¢ãªããã倧ããªãµã€ãºã®ãã¡ã€ã«ãåŠçããããšãå€ã
ãããããŒã¿ãã¹ããªãŒãã³ã°ã§æ±ãããšã«ãããã¡ã¢ãªäžè¶³ã«ãªããªãããã«åŠçãããããšãã§ããŸãã(ãã¡ã€ã«ã®åæèªã¿èŸŒã¿ã®ã¡ã¢ãªäžè¶³ã«ã¯æ³šæãå¿
èŠã)
- Batch Job ã¯éåæã®ãã«ãã¹ã¬ããåŠçã§ãããbatch block size ã«å¿ããŠãåã¬ã³ãŒããã°ã«ãŒãã³ã°ãåŠçãããŸãã
### ã¢ãžã¥ãŒã«5:
#### ããŒã¿å€æã®è€éæ§ : Common Data Model (å
±æããŒã¿ã¢ãã«) ã®æå¹æŽ»çš
- N\*N(-1) => **O(N^2)**
6 (6*5) -> 30
7 (7*6) -> 42
- 2N => O(N)

### ããªããŒã·ã§ã³ã¢ãžã¥ãŒã«
- fail fast (éå®³ãæ©æã«çºèŠå¯èœ) ã«ãªãããã«ããªããŒã·ã§ã³ãããã
- isNotNull? isNumber? etc...
https://docs.mulesoft.com/jp/validation-connector/1.4/validation-examples
- ALL
- å
šéšã®æ€èšŒãéããšOK
- [1,2,3] > 2ã§ãããŠãã3ãå®è¡ > VALIDATION:MULTIPLE ã®ãšã©ãŒãåã
- 3ã€äž,2ã€ã§ãããäŸ:
```
Message : test is not a valid email address
value was expected to be null
Element : testFlow/processors/1 @ test:test.xml:14 (All)
Element DSL : <validation:all doc:name="All" doc:id="89e83d21-a4aa-4b47-acf6-bdb9a7a632ff">
<validation:is-email doc:name="Is email" doc:id="081b258d-75e8-4db5-a64a-f4532faeb54a" email="#[payload]"></validation:is-email>
<validation:is-null doc:name="Is null" doc:id="2c6a2c24-964e-488f-b97e-acf6786df0e6" value="#[payload]"></validation:is-null>
<validation:is-not-null doc:name="Is not null" doc:id="678c7c2c-20f7-423f-8032-61f22b01a7d1" value="#[payload]"></validation:is-not-null>
</validation:all>
Error type : VALIDATION:MULTIPLE
FlowStack : at testFlow(testFlow/processors/1 @ test:test.xml:14 (All))
```
- ANY
- 1ã€ã§ãæ€èšŒãéããšOK
### Common Data Modelãã®ã€ã¡ãŒãžã®äžäŸ
1. ããŒã¿ã®ååŸ: GET
===API ã¯ã©ã€ã¢ã³ã ===
â â
EAPI //ã¯ãšãªãã©ã¡ãŒã¿? URL ãã©ã¡ãŒã¿?
â â
PAPI //ããžãã¹ããžãã¯ããªãŒã±ã¹ãã¬ãŒã·ã§ã³
â â
SAPI //åã·ã¹ãã åºæã®ããŒã¿å(ã·ã¹ãã æ¯ã®éããåžå)ããããŒã¿ãååŸ->Common Data Model(該åœããå Žå)ãžå€æ
=== ããã¯ãšã³ãã·ã¹ãã ===
2. ããŒã¿ã®äœæ: POST
===API ã¯ã©ã€ã¢ã³ã===
â â
EAPI //åã¯ã©ã€ã¢ã³ãåºæã®ããŒã¿å? ãã©ãŒãããã¯? (JSON etc...) -> Common Data Model (該åœããå Žå)ã(API ã¯ã©ã€ã¢ã³ãããšã®éããåžå)
â â
PAPI //ããžãã¹ããžãã¯ããªãŒã±ã¹ãã¬ãŒã·ã§ã³
â â
SAPI //Common Data Model(該åœããå Žå)->åã·ã¹ãã åºæã®ããŒã¿åãžã®å€æ (ã·ã¹ãã æ¯ã®éããåžå)
=== ããã¯ãšã³ãã·ã¹ãã ===
3. API-led ã®ãã¿ãŒã³ã«åœãŠã¯ãŸããªãå Žå
===ããŒã¿ãœãŒã¹,Queue===
â
E(?)/P(?)APIïŒããããAPIã§ãªã?//JSON, CSV, XML ... ->Common Data Model+ããžãã¹ããžãã¯,ãªãŒã±ã¹ãã¬ãŒã·ã§ã³
â
SAPI /Common Data Model(該åœããå Žå)ã-> åã·ã¹ãã åºæã®ããŒã¿åãžã®å€æ (ã·ã¹ãã æ¯ã®éããåžå)
=== ããã¯ãšã³ãã·ã¹ãã ===
#### EIP
https://www.enterpriseintegrationpatterns.com/
https://docs.mulesoft.com/jp/mule-runtime/4.4/understanding-enterprise-integration-patterns-using-mule
#### DDD
[DDD飿°ã«æ§ããDomain-Driven Designã®ãšãã»ã³ã¹](https://www.ogis-ri.co.jp/otc/hiroba/technical/DDDEssence/chap1.html)
#### Canonical Data Model
[Why is Canonical Data Model is anti-pattern?](https://teivah.medium.com/why-is-a-canonical-data-model-an-anti-pattern-441b5c4cbff8)

> You should try to implement **the bounded context concept meaning one model per context with explicit boundaries between the contexts**.
student manual p.147
### ã¢ãžã¥ãŒã«6: Mule ã¢ããªã±ãŒã·ã§ã³ã®ãã¹ãæŠç¥ã®èšèš
> Untested code is broken code.
#### MUnit ãã¹ã
Assert (ã¢ãµãŒã, æ€èšŒ)
[Assert Equals](https://docs.mulesoft.com/jp/munit/2.3/assertion-equals-processor)
[Assert Expression](https://docs.mulesoft.com/jp/munit/2.3/assertion-expression-processor)
[Assert That](https://docs.mulesoft.com/jp/munit/2.2/munit-matchers)
#### Spy
[Spy](https://docs.mulesoft.com/jp/munit/2.3/spy-event-processor) ããã»ããµã§ã¯ãã€ãã³ãããã»ããµã®ã³ãŒã«ååŸã§äœãèµ·ããŠããããç£èŠã§ããŸã
#### MUnit ãã¹ãã®ãã©ã¡ãŒã¿å
yaml ãšçµã¿åãããŠãè€æ°ã®ãã¹ãã±ãŒã¹ãäœæ
```
hello: # test case 1
inputPayload: "hello" # ${inputPayload}
expectedPayload: "Hello back!" # ${expectedPayload}
goodbye: # test case 2
inputPayload: "goodbye" # ${inputPayload}
expectedPayload: "Goodbye!" # ${expectedPayload}
default: # test case 3
inputPayload: "default" # ${inputPayload}
expectedPayload: "I do not understand that" # ${expectedPayload}
```
Set Event to Behavior ãšãªã¢
- Value (å€): `${inputPayload}`
- Media Type (ã¡ãã£ã¢ã¿ã€ã): `text/plain`
Assert Equal to Validation ãšãªã¢
- Actual (DataWeave åŒã¢ãŒã): `payload`
- Expected (ãªãã©ã«ã¢ãŒã): `${expectedPayload}`
- Message (ãªãã©ã«ã¢ãŒã): `Payload did not match expected`
### MUnit Test Tags
`mvn clean test -Dmunit.tags=aTagName`
https://docs.mulesoft.com/jp/munit/2.3/munit-test-concept#%E3%82%BF%E3%82%B0%E5%B1%9E%E6%80%A7%E3%81%AE%E3%83%86%E3%82%B9%E3%83%88
## Day 4
### ã¢ãžã¥ãŒã«7: ãããã€ã¡ã³ãæŠç¥ã®æ±ºå®ãšéçº
#### CloudHub(CH)
CH ã¢ããªã±ãŒã·ã§ã³ã®ã¹ã±ãŒãªã³ã° (0.1 -> 0.2)
#### Customer-hosted Mule ã©ã³ã¿ã€ã (ãªã³ãã¬ãã¹, AWS, Azure..)
- Mule ã®æåèµ·å
Windows: `mule`
Mac: `./mule` (sudo spctl --master-disable)
- Mule ã®æåã¹ããã
Ctrl + C
- ã¢ããªã±ãŒã·ã§ã³ã®ããã〠(æåã§ã Runtime Manager ã䜿ã£ãŠãåã)
appsããã©ã«ãã« jar ãã¡ã€ã«ãå±éãããŠãã
- conf/wrapper.conf -> ã©ã³ã¿ã€ã ã®èšå®ãèšè¿°å¯èœ
193è¡ç® default => 1024ãããã§ã¯ã¡ã¢ãªã®æå°ã倿Ž
`wrapper.java.initmemory=512`
197è¡ç® default => 1024ãããã§ã¯ã¡ã¢ãªã®æå€§ã倿Ž
`wrapper.java.maxmemory=512`
- Runtime manager ã« Mule ã©ã³ã¿ã€ã (ãµãŒããŒïŒã®ç»é²
1.Runtime Manager
2.Server
3.Add Server
4.ååãèšå®
5.ã³ãã³ããã³ããŒ
- bin dir
Mac: ` ./amc_setup -H 52311cf0-5123-4d07-908f-39289b6de627---610287 node1`
Windows (_./ããåé€ïŒ_) : `amc_setup -H 52311cf0-5123-4d07-908f-39289b6de627---610287 node1`
- Runtime Manager Agent ãããªã³ãã¬ãã¹ãšãAnypoint Platform ã®ã³ãã¯ã·ã§ã³ããµããŒãããïŒ
Hybrid ç°å¢ã§ Runtime ã管çã»ç£èŠããããšãå¯èœã«ãªã)
#### VisualVM
- ããã»ã¹ã確èª
ãã§ãã¯ãã€ã³ã: ã¡ã¢ãªã¯ 512 MBã«å€ãã£ãŠããïŒ
#### Domain ãããžã§ã¯ã
1ã€ã®ã©ã³ã¿ã€ã ã§è€æ°ã®ã¢ããªã±ãŒã·ã§ã³ãå®è¡ããéã«ãèšå®ãå
±æãããããšãå¯èœ
äŸ: appA ãš appB ã®ã©ã¡ããããdomainX ã® HTTP Listner Config ãåç
§ãã => ããŒãã®ç«¶åãè§£æ¶ïŒ
â» Customer-hosted Mule ã©ã³ã¿ã€ã ã§ã®ã¿å¯èœãªæ§æ
â» CloudHub ã RTF ã¯ãã€ã¯ããµãŒãã¹ãšã㊠1Mule=1Appãªã®ã§ããããããã¡ã€ã³ãããžã§ã¯ãã®å¿
èŠããªãã
â»1 Mule <=> N åã® App ã®æ§æãå¯èœãã§ã¯ããããã¢ããªã±ãŒã·ã§ã³ã®æ°ãå¢ãããšãMule ããŒãžã§ã³ã®ã¢ããããŒããåèµ·åã«éããŠã®åœ±é¿ç¯å²ãåºããªããããæ³šæãå¿
èŠã
ã
#### RTF (VM / on Self-managed k8s)
1. RTF-VM
è³æ: https://docs.mulesoft.com/jp/runtime-fabric/1.9/index-vm-bare-metal
â»ä»¥å㯠RTF Appliance ãšåŒã°ããŠããŸãã
- ä»®æ³ãã·ã³ (VM) ã§ k8s ã¯ã©ã¹ã¿ãæ§æ
- ã€ã³ãã©ãïŒe.g AWS, Azure) ã¯ã客æ§ãçšæãk8s ã¯ã©ã¹ã¿ãæ§æããããã®ã¹ã¯ãªããã Docker ã€ã¡ãŒãž etc... ã¯MuleSoft ãçšæ
- 2 ã«æ¯ã¹ããšã"æ¯èŒç" å°éç¥èã¯å°ãªããŠè¯ãã(ãã©ãã«ã·ã¥ãŒãã£ã³ã°ãèãããšãç¥èãçµéšã¯ããã«è¶ããããšã¯ãªãã§ãïŒ)
2. RTF on Self-managed k8s
è³æ: https://docs.mulesoft.com/jp/runtime-fabric/1.9/index-self-managed
- EKS, AKS, GKE ãªã©ã®ç®¡çå k8s ãµãŒãã¹ã§å®è¡
- 1 ã«æ¯ã¹ãŠ å°éç¥èãå¿
èŠ
#### Gold vs Platinum & Titanuim
Platinum & Titanuimãã§ã¯ãCloudHub vCore ãã Customer-hosted ã©ã³ã¿ã€ã Core ãžã®æ¯æ¿ãå¯èœ (ãµããŒãã±ãŒã¹ãäœæ)
è³æ: https://help.mulesoft.com/s/article/How-to-Transfer-Mulesoft-on-Premise-Core-Licenses-to-Cloudhub-vCore-Licenses-or-Vice-Versa
- APIåŒã³åºããšã¡ãã»ãŒãžã³ã°ã«é¢ããå
šãŠã®ã¡ã¿ããŒã¿ãå«ãããªã³ãã¬ãã¹åŠçã®å¶çŽ
- ã³ã³ãããŒã«ãã¬ãŒã³: Anypoint PCE
- ã©ã³ã¿ã€ã ãã¬ãŒã³: ã¹ã¿ã³ãã¢ããŒã³
- åžå Žæå
¥(time-to-market)ã®æé
- ã³ã³ãããŒã«ãã¬ãŒã³: MuleSoft-hosted Anypoint Platform
- ã©ã³ã¿ã€ã ãã¬ãŒã³: **CloudHub**
- IT éçšã®åŽåã®åæž
- ã³ã³ãããŒã«ãã¬ãŒã³: MuleSoft-hosted Anypoint Platform
- ã©ã³ã¿ã€ã ãã¬ãŒã³: **CloudHub**
- ãªã³ãã¬ãã¹/DCããŒã¿ãœãŒã¹ãžã®ã¢ã¯ã»ã¹
- ã³ã³ãããŒã«ãã¬ãŒã³: MuleSoft-hosted Anypoint Platform
- ã©ã³ã¿ã€ã ãã¬ãŒã³: **CloudHub** [(VPN,VPC Peering, Transit Gateway, DirectConnect)](https://docs.mulesoft.com/runtime-manager/vpc-connectivity-methods-concept), RTF, ã¹ã¿ã³ãã¢ããŒã³
- è€æ°ã® Mule ã¢ããªã±ãŒã·ã§ã³éã®åé¢
- ã³ã³ãããŒã«ãã¬ãŒã³: MuleSoft-hosted Anypoint Platform
- ã©ã³ã¿ã€ã ãã¬ãŒã³: CloudHub, RTF, ã¹ã¿ã³ãã¢ããŒã³(1 Mule <-> n åã®ã¢ããªã±ãŒã·ã§ã³ãå¯èœ)
- Mule ã©ã³ã¿ã€ã ã®ãã¥ãŒãã³ã°
- ã³ã³ãããŒã«ãã¬ãŒã³: MuleSoft-hosted Anypoint Platform
- ã©ã³ã¿ã€ã ãã¬ãŒã³: ã¹ã¿ã³ãã¢ããŒã³(å¿
èŠæ§ãèæ
®)
- ã©ã³ã¿ã€ã ãã¬ãŒã³ã®æ¡åŒµæ§ (scalability)
- ã³ã³ãããŒã«ãã¬ãŒã³: MuleSoft-hosted Anypoint Platform
- ã©ã³ã¿ã€ã ãã¬ãŒã³: CloudHub(CloudHub ã®æ çµã¿ã®äžã§æ¡åŒµã¯å¯èœ), RTF, ã¹ã¿ã³ãã¢ããŒã³
- ã¹ã±ãŒãªã³ã° -> æ°Žå¹³(ã¹ã±ãŒã«ã¢ãŠã/ã€ã³) & åçŽ(ã¹ã±ãŒã«ã¢ãã/ããŠã³)
- ã³ã³ãããŒã«ãã¬ãŒã³: MuleSoft-hosted Anypoint Platform
- ã©ã³ã¿ã€ã ãã¬ãŒã³: CloudHub(ãªãŒãã¹ã±ãŒãªã³ã°: ELAå¥çŽã®ã¿), RTF
- [RTF](https://docs.mulesoft.com/jp/runtime-fabric/1.4/deploy-resource-allocation)
- [CH+ELA](https://docs.mulesoft.com/jp/runtime-manager/autoscaling-in-cloudhub)
- æ°èŠãªãªãŒã¹ã®ããŒã«ã¢ãŠã(ãŒãããŠã³ã¿ã€ã ã§ã®ãããã€ã¡ã³ã)
- ã³ã³ãããŒã«ãã¬ãŒã³: Anypoint Platform(US/EU)
- ã©ã³ã¿ã€ã ãã¬ãŒã³: CloudHub, RTF
- [RTF æ¬çªèšå®](https://docs.mulesoft.com/jp/runtime-fabric/1.7/architecture#%E6%9C%AC%E7%95%AA%E8%A8%AD%E5%AE%9A)
### ã¢ãžã¥ãŒã«8: é©åãªã¹ããŒã (ç¶æ
) ã®ç¶æãšç®¡çã®ãªãã·ã§ã³èšèš
ã»ãããã€ã®èšå®ã«ãã£ãŠç°ãªãç¶æ
ã®ä¿æç®¡çãªãã·ã§ã³

#### CloudHub - Persistent Queue (ã¯ã©ãŠãã®æ°žç¶åãã¥ãŒ)
https://help.mulesoft.com/s/article/Mule-Batch-Process-and-CloudHub-Persistent-Queues
â» Batch åŠçã§ã¯ããã©ãŒãã³ã¹ã«åœ±é¿ãã!!!
以äžã®ã³ãã³ãã§ãVM ã®persistent queue ãæå¹ã«ãã€ã€ãbatch queue ã§ã¯ persistent queue ã䜿çšããªãããšããèšå®ãå¯èœ
`batch.persistent.queue.disable=true`
#### Object Store on CloudHub
- Object Store V2 ã®å¶é
è³æ: https://docs.mulesoft.com/jp/object-store/#object-store-%E3%81%AB%E9%96%A2%E3%81%99%E3%82%8B%E3%83%A1%E3%83%A2
å¶éã«åŒã£ããããã® (10TPS/100TPS, 30 days TTL )ããåèµ·åã§å€±ãããŠãè¯ããã®ãå
±æããªããŠãè¯ããã®ã¯ Object Store V2 ã§ã¯ãªã non persistent ã®äœ¿çšãæ€èš
- Store Object Store V2
- ãšã³ããã€ã³ã: /object-store/storePersistent?key=persistent&value=cloudHubValue
Object Store ã¯ããŒããªã¥ãŒãã¢
```
{
"persistent": "cloudHubValue"
}
```
- Retrieve ObjetStore V2
- ãšã³ããã€ã³ã: /object-store/retrievePersistent?key=persistent
retuens `"cloudHubValue"`
- Store NP ObjetStore
- ãšã³ããã€ã³ã: /object-store/storeNonPersistent?key=nonPersistent&value=cloudHubValue
- Retrieve NP ObjetStore
- ãšã³ããã€ã³ã: /object-store/retrieveNonPersistent?key=nonPersistent
- [ ] åèµ·ååŸãCloudHub Object Store V2 ã® ããŒã¿ã¯æ®ã£ãŠãã?
- [ ] /object-store/retrieveNonPersistent?key=nonPersistent
returns `null!`
- [ ] /object-store/retrievePersistent?key=persistent
returns `cloudHubValue!`
#### Clustered Mule ã©ã³ã¿ã€ã (HZ IMDG)
##### mule.bat -M-Dhttp.port=9081 ã§ããŒãã®ã³ã³ããªã¯ããé¿ãã!

##### cluster profile (performance/reliable[ããã©ã«ã])
HZ ã䜿ããªããªãã·ã§ã³: `mule.cluster.storeprofile=performance`
#### ã¹ã¿ã³ãã¢ããŒã³ã©ã³ã¿ã€ã Object Store
- persistent(æ°žç¶ç)
- .mule > <appname> > objectstore ã«ä¿åãããŠãã
- transient(äžæç)
- ã¡ã¢ãª
##### stateful-playground.jar (ã¹ã¿ã³ãã¢ããŒã³)
- 1.Store Persistent
- http://localhost:8081/object-store/storePersistent?key=persistent&value=Standalone!
- 2.Store NonãPersistent
- http://localhost:8081/object-store/storeNonPersistent?key=nonPersistent&value=Standalone!
- 3.Retrieve Persistent
- http://localhost:8081/object-store/retrievePersistent?key=persistent
`Standalone!`
- 4.Retrieve NonPersistent
- http://localhost:8081/object-store/retrieveNonPersistent?key=nonPersistent
`Standalone!`
- [ ] åèµ·ååŸã ã¹ã¿ã³ãã¢ããŒã³ã® Object Store ã®ããŒã¿ã¯æ®ã£ãŠããïŒïŒ
- http://localhost:8081/object-store/retrievePersistent?key=persistent
- standaloneValue!!! (persistent = ãã£ã¹ã¯ã«æžã蟌ã)
- http://localhost:8081/object-store/retrieveNonPersistent?key=nonPersistent
- null (non persistent = ã¡ã¢ãªã«ä¿æãã = åèµ·åã«èããããªãã£ã...)
#### CloudHub Persistent Queue(æ°žç¶åãã¥ãŒ)
- SQS ã®ä»çµã¿ã䜿çšããã¯ã©ãŠãããŒã¹ã®æ°žç¶åãã¥ãŒ(ã¯ãŒã«ãŒéã§å
±æå¯èœ && ãªã¹ã¿ãŒãã«èãã)
- **Batch Queue ã«ãæ°žç¶åãã¥ãŒã䜿çšãããšããã©ãŒãã³ã¹ã«åœ±é¿ããã**
`batch.persistent.queue.disable=true`
https://help.mulesoft.com/s/article/Mule-Batch-Process-and-CloudHub-Persistent-Queues
#### Cache ã¹ã³ãŒã
Object Store ã䜿çšããŠãäžå®æéãã£ãã·ã¥ã䜿çšããä»çµã¿
#### Idempotent Message Validatorãã¹ã³ãŒã
Object Store ã䜿çšããŠãåäžã® ID ãæã€ããŒã¿ããéè€ããŠåŠçãããªãããã«ããä»çµã¿
Q.
1. Cloudhubã®è€æ°ã¯ãŒã«ãŒæ§æ
2. RTFã®éã¯ã©ã¹ã¿æ§æ(pod/replica)
3. RTFã®ã¯ã©ã¹ã¿ãªã³ã°æ§æ
ã®3ã€ãæ¯èŒãããšãã«ãã¢ããªã±ãŒã·ã§ã³ã®ç¶æ
管çã®èгç¹ã§ã¯ã1.ãš2.ã¯åãã§ããã2.ãš3.ã¯hazelcastã§OSãšVMãå
±æã§ããéãããããšããçè§£ã§ãã£ãŠãŸããïŒã§ããã°ã1.ãš3.ã®éãã2.ãš3.ã®éããšèããŠããã§ããïŒ
A. Yes! -> 1ãš3ã®éãã¯
1. OS V2,ã¯ã©ãŠãããŒã¹ã®persistent Queueã䜿çšå¯èœ
3. persistent gateway(psql)ã§OSãå
±æå¯èœã«ããããšãã§ãã
### ã¢ãžã¥ãŒã«9: ãã°
#### CloudHub log
100MB or 30 days
https://docs.mulesoft.com/runtime-manager/custom-log-appender#create-your-log4j-configuration
#### Anyoint Mnitoring Log
https://help.mulesoft.com/s/article/Anypoint-Monitoring-Log-FAQ
> What are the storage limits for Anypoint Monitoring logs?
For Titanium Subscription, you will get 200 GB per production core. Please note that the storage is shared across globally, meaning that if you only have one production core, you will get **200 GB** of storage that is shared across all apps. This storage is also shared across both logs and metrics usage.
## Day 5
### ã¢ãžã¥ãŒã« 10: å¹ççã§èªååããããœãããŠã§ã¢éçºã©ã€ããµã€ã¯ã« (SDLC) ã®èšèš
#### maven
https://maven.apache.org/download.cgi
- ã©ã€ããµã€ã¯ã«
https://maven3.kengo-toda.jp/primer/build-lifecycle
- Mule Maven Plugin
https://docs.mulesoft.com/jp/mule-runtime/4.3/mmp-concept
https://docs.mulesoft.com/jp/mule-runtime/4.3/deploy-to-cloudhub
- Connected App
https://docs.mulesoft.com/jp/access-management/connected-apps-overview
#### Anypoint CLI
https://docs.mulesoft.com/jp/runtime-manager/anypoint-platform-cli
1. ã€ã³ã¿ã©ã¯ãã£ãã¢ãŒã
`npm install -g anypoint-cli@latest`
```anypoint-cli --username=XXX --password=YYY --organization=ZZZ --environment=Sandbox```
```anypoint-cli --username=asakaguchi_training_30jan2022 --password=MuleSoft2022 --organization="MuleSoft Training" --environment=Sandbox```
äŸ: Runtime Manager ã¢ã©ãŒãã®äžèЧãååŸ
`runtime-mgr cloudhub-alert list`
2. ã¹ã¯ãªããã£ã³ã°ã¢ãŒã
#### Anypoint Platform REST API ã®åŒã³åºãæ¹
##### ã¬ãŒãå¶é
https://help.mulesoft.com/s/article/Anypoint-Platform-REST-API-Rate-Limit#:~:text=Anypoint%20platform%20detects%20usage%20based,from%20an%20individual%20client%20IP.
> As a guidance, it is recommended that applications do not exceed 15 requests per second from an individual client IP.
1. https://anypoint.mulesoft.com/accounts/login ã« POST ãªã¯ãšã¹ããéä¿¡ããŸãã Body ã«ã¯ä»¥äžã®å
容ãèšå®ããŠãã ããã
content-type: application/json
`{
"username": "REPLACE_HERE!",
"password": "REPLACE_HERE!"
}`
2. 403 Forbidden ãinvalid csrf tokenããšã©ãŒã衚瀺ãããå Žåã¯ãAdvanced REST Client ã® _csrf ã¯ãããŒãåé€ããŸãã
... > Request > Web session > Cookie manager
3. å床ãªã¯ãšã¹ããéä¿¡ãããš 200 OK ãš access_token ãè¿ãããŸãã
```
{
"access_token": "824767b4-1e87-4b56-9896-99878491f5f2",
"token_type": "bearer",
"redirectUrl": "/home/"
}
```
4. ãã®ã¢ã¯ã»ã¹ããŒã¯ã³ã Authorization ããããŒã«äœ¿çšããŠã Anypoint Platform API ãåŒã³åºãããšãå¯èœã«ãªããŸãã
[Anypoint Platform API](https://anypoint.mulesoft.com/exchange/portals/anypoint-platform/)
äŸ: Authorization: Bearer 80566d46-3827-463c-b624-c36bae02d0df
Access Managemnt API
https://anypoint.mulesoft.com/accounts/api/users/me
### ã¢ãžã¥ãŒã« 11: Mule ã¢ããªã±ãŒã·ã§ã³ã«ããããã©ã³ã¶ã¯ã·ã§ã³ (TX)ã管çèšèš
â» TX = ãã©ã³ã¶ã¯ã·ã§ã³
ãã¹ãŠã®ã¡ãã»ãŒãžåŠçã¯åäžã¹ã¬ããã§è¡ã
#### åã蟌ã¿å autodiscovery Basic Endpoint
https://docs.mulesoft.com/jp/api-manager/2.x/org-credentials-config-mule4#anypoint-studio-7-%E3%81%A7%E3%81%AE%E3%83%AD%E3%82%B0%E3%82%A4%E3%83%B3%E6%83%85%E5%A0%B1%E3%81%AE%E8%A8%AD%E5%AE%9A
https://docs.mulesoft.com/jp/api-manager/2.x/configure-autodiscovery-4-task
```INFO 2022-02-04 11:30:45,811 [agw-policy-set-deployment.01] com.mulesoft.mule.runtime.gw.policies.deployment.DefaultPolicyDeployer: Applied policy rate-limiting-2521374 version 1.3.5 to API COVID-19 SAPI-v1-v1:17609769 (17609769) in application covid19-api```
#### ã·ã³ã°ã«ãªãœãŒã¹ TX
#### XA TX
è€æ°ã®ããŒã¿ãœãŒã¹ãè·šãã ãã©ã³ã¶ã¯ã·ã§ã³
bitronix XA ãããžã£ãŒ
<bti:transaction-manager doc:name="Bitronix Transaction Manager" doc:id="15009545-b62f-4210-972d-df654f3a5f6c" />
#### XA ãã©ã³ã¶ã¯ã·ã§ã³ãã³ãºãªã³ã®åŒã³åºãäŸ
`/init` -> ããŒãã«ãäœæ
`/drop` -> ããŒãã«ããããã
`/select` -> ã»ã¬ã¯ã
`/doStuffAsXA?id=1&haveError=false&customerName=MaxMule`
-> ãšã©ãŒãªã XA TX
`/doStuffAsXA?id=2&haveError=true&customerName=MaxineMule`
-> ãšã©ãŒãã XA TXã(ããŒã«ããã¯ãããïŒ)
`/doStuffWithoutTransaction?id=3&haveError=true&customerName=AkiraMule`
-> ãšã©ãŒãã ãã©ã³ã¶ã¯ã·ã§ã³ãªã
#### Saga Pattern
- ã€ãã³ãã³ãªãªã°ã©ãã£ãŒãã¿ãŒã³
- ãªãŒã±ã¹ãã¬ãŒã¿ãŒãã¿ãŒã³
#### JMS ã«ã¯ TX ãš ACK ã®ä»çµã¿ããã (ã©ã¡ããããéžæ)
[ACK]( https://docs.mulesoft.com/jp/jms-connector/1.7/jms-ack)
1. AUTO (ããã©ã«ã)
- å®äºãããã㯠On Error Continue ã§ ACK
2. IMMEDIATE
- åãåã£ãã ACK (ä¿¡é Œæ§...?)
- Mule 3 ã§ã¯ NONE ãšåŒã°ããŠãã
3. MANUAL
- ACK ãªãã¬ãŒã·ã§ã³ããããŒã®äžã§èšå®
4. DUPS_OK
- ãŸãšã㊠ACK (éè€ã®å¯èœæ§)
### ã¢ãžã¥ãŒã« 12: ä¿¡é Œæ§ (reliability) ç®æšã«åããèšèš
éåæãã¡ãã»ãŒãžã®åªå€±ãé²ããè² è·åæ£
- Until Successful
```
maxRetries="5"
millisBetweenRetries="1000"
```
Until Successful + Try + **On Error Continue** (Successfulãã!ãšæãããŸãã)

- åæ¥ç¶æŠç¥
- åããªããªãŒããªã·ãŒ(ã¡ãã»ãŒãž)
- Transaction(TX)
- ãšã©ãŒåŠç
- First Successful
### ã¢ãžã¥ãŒã« 13: é«å¯çšæ§ (HA) ç®æšã«åããèšèš
#### Server Group (Cluster ãšã¯ç°ãªã)
https://docs.mulesoft.com/jp/runtime-manager/server-group-about
-> Scheduler ã®å®è¡ãéè€ããããããŸã§ã°ã«ãŒãã³ã°ã®ã¿
https://docs.mulesoft.com/jp/runtime-manager/cluster-about
-> Scheduler 㯠primary node ã®ã¿ (performance/relible[HZ IMDG])
> ãµãŒãã°ã«ãŒããšã¯ç°ãªããã¯ã©ã¹ã¿å
ã®ã¢ããªã±ãŒã·ã§ã³ã€ã³ã¹ã¿ã³ã¹ã¯çžäºãèªèããå
±éã®æ
å ±ãå
±æããŠãç¶æ³ãåæãããŸãã1 å°ã®ãµãŒããæ
éããå Žåã¯ãå¥ã®ãµãŒããã¢ããªã±ãŒã·ã§ã³ã®åŠçãåŒãç¶ããŸãã1 ã€ã®ã¯ã©ã¹ã¿ã¯è€æ°ã®ã¢ããªã±ãŒã·ã§ã³ãå®è¡ã§ããŸãã
NEW! Q.CloudHub persistent VM quque ã¯ã©ã®ã¿ã€ãã³ã°ã§ãã¥ãŒãããªããªã?
CloudHub ã«éããã VM Listnerã®[åããªããªæŠç¥æ¬¡ç¬¬](https://docs.mulesoft.com/jp/mule-runtime/4.4/redelivery-policy
) (ãã¡ãã: https://docs.mulesoft.com/jp/vm-connector/2.0/vm-reference#RedeliveryPolicy)
åŠçã®éäžã§ãšã©ãŒãçºçããå Žåãå床å¥ã®ããŒã/ã¯ãŒã«ãŒããããã¯ã¢ãããããæå®ãããåæ°åååŠçãããã -> æå®ãããåæ°ãè¶
ããå Žåã VM:RETRY_EXHAUSTED
ãšã©ãŒãçºçããã

https://help.mulesoft.com/s/article/CloudHub-Persistent-Queues-Explained
https://docs.mulesoft.com/jp/runtime-manager/managing-queues
> One time only message delivery. One time only message delivery cannot be guaranteed with CloudHub Persistent Queues.
> Duplicate messages can be sent. If your solution requires strict one time only delivery, do not use CloudHub Persistent Queues.
#### ObjectStore
- **Key-Value**
- ã¹ãã¬ãŒãž
- CloudHub OS v2 - Cloud
- CloudHub non persistent - in-memory (æ°žç¶åãªã, å
±æãªã)
- StandAlone - disk
- StandAlone - in-memory - Cluster - HZ IMDG
- Cluster - JDBC
- RTF - in-memory
- RTF - HZ IMDG
- RTF - persistence gateway(psql)
https://github.com/mulesoft/docs-connectors/blob/latest/object-store/0.3.9/modules/ROOT/pages/index.adoc
### ã¢ãžã¥ãŒã« 14: ãããã€ãã Mule ã¢ããªã±ãŒã·ã§ã³ã®ããã©ãŒãã³ã¹æé©å
#### performance test.xls
`fileStreaming/createFile?numOfRows=500000`
`fileStreaming/createFile?numOfRows=4000000`
mime type stream setting
false -> true

filestore in-memory repeatable stream âin-memory repeatable stream

```
ERROR 2022-02-04 15:20:01,303 [[MuleRuntime].uber.49: [mod14-performance-playground].fileStreamingFlow.CPU_INTENSIVE @ca1b630] [processor: ; event: 7ba498b0-8582-11ec-8c39-0028f8083c74] org.mule.runtime.core.internal.exception.OnErrorPropagateHandler:
********************************************************************************
Message : "org.mule.runtime.api.streaming.exception.StreamingBufferSizeExceededException - Buffer has exceeded its maximum size of 1048576
org.mule.runtime.api.streaming.exception.StreamingBufferSizeExceededException: Buffer has exceeded its maximum size of 1048576, while writing Json at
2105| fun map <T,R>(@StreamCapable items: Array<T>, mapper: (item: T, index: Number) -> R ): Array<R> = native("system::ArrayMapFunctionValue")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^.
2105| fun map <T,R>(@StreamCapable items: Array<T>, mapper: (item: T, index: Number) -> R ): Array<R> = native("system::ArrayMapFunctionValue")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Trace:
at dw::Core::main (line: 2105, column: 99)" evaluating expression: "%dw 2.0
//tuning: try changing the output directives:
//output application/json deferred=true,bufferSize=819200
//output application/json deferred=true,bufferSize=81920
//output application/json deferred=true
output application/json
---
payload map ( payload01 , indexOfPayload01 ) -> {
firstValue: payload01.col1,
secondValue: upper ( payload01.col2)
}".
Element : fileStreamingFlow/processors/2 @ mod14-performance-playground:fileStreaming.xml:34 (turn CVS into output json structure.. to tune: see output directive)
Element DSL : <ee:transform doc:name="turn CVS into output json structure.. to tune: see output directive" doc:id="e97e57ff-90ac-4d85-b081-14264a3ce1b3">
<ee:message>
<ee:set-payload><![CDATA[
%dw 2.0
//tuning: try changing the output directives:
//output application/json deferred=true,bufferSize=819200
//output application/json deferred=true,bufferSize=81920
//output application/json deferred=true
output application/json
---
payload map ( payload01 , indexOfPayload01 ) -> {
firstValue: payload01.col1,
secondValue: upper ( payload01.col2)
}
]]></ee:set-payload>
</ee:message>
</ee:transform>
Error type : MULE:EXPRESSION
FlowStack : at fileStreamingFlow(fileStreamingFlow/processors/2 @ mod14-performance-playground:fileStreaming.xml:34 (turn CVS into output json structure.. to tune: see output directive))
(set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************
```
https://docs.mulesoft.com/dataweave/2.4/dataweave-memory-management
https://docs.mulesoft.com/jp/mule-runtime/4.4/intro-transformations
https://docs.mulesoft.com/dataweave/2.4/dataweave-streaming
>To stream successfully, it is important to understand the following:
The basic unit of the stream is specific to the data format.
The unit is a record in a CSV document, an element of an array in a JSON document, or a collection in an XML document.
Streaming accesses each unit of the stream sequentially.
Streaming does not support random access to a document.
#### ã詊ããã ãã!
- mime-type stream:true
- TM: deferred=true
> When in deferred mode, DataWeave can also pass streamed output data directly to a message processor without saving it to the disk. This behavior enables DataWeave and Mule to process data faster and consume fewer resources than the default processes for reading and writing data.
- TM: bufferSize=819200 // default 8192
- TM: indent=flase
- ???) CSV - > **Java** -> JSON ãžã®å€æ

### ã¢ãžã¥ãŒã« 15: ã»ãã¥ã¢ãª Mule ã¢ããªã±ãŒã·ã§ã³ãšãããã€ã¡ã³ãã®èšèš
å€éš IdP
- ID Management, User Management
- Client Management
https://docs.mulesoft.com/jp/mule-runtime/4.4/secure-configuration-properties#secure_props_tool
- Secure Config Properties
https://docs.mulesoft.com/jp/mule-runtime/4.4/secure-configuration-properties
- https://docs.mulesoft.com/jp/mule-runtime/4.4/secure-configuration-properties#%E6%8B%A1%E5%BC%B5%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%BC%E3%83%AB%E3%82%92%E3%82%A4%E3%83%B3%E3%82%B9%E3%83%88%E3%83%BC%E3%83%AB%E3%81%99%E3%82%8B
```
encrypted:
value1: "![nHWo5JhNAYM+TzxqeHdRDXx15Q5R56YVGiQgXCoBCew=]"
value2: "![nHWo6XyCADP+TzxqeHdRDXx15Q5R56YVGiQgXCoDFaj=]"
testPropertyA: "testValueA"
testPropertyB: "testValueB"
```

`${secure::encrypted.value1}`
`${testPropertyA}`
### ã¢ãžã¥ãŒã« 16: Mule ã¢ããªã±ãŒã·ã§ã³éã®ãããã¯ãŒã¯éä¿¡ãã»ãã¥ã¢ã«ãã
#### VPCã¯å€§ããã«!
äžåºŠ VPC ãäœæãããšãããŠã³ã¿ã€ã ãªãã§CIDRãããã¯ãå調æŽã§ããªãã
#### VPC(CIDR)ã®èšç®æ¹æ³
10.0.0.1/32 -> 1 IP
32 - 32 = 2^0 = 1
10.0.0.1/24 -> 256 IP
32 - 24 = 2^8 = 256 (25 apps?)
10.0.0.1/16 -> 65536 IP
32 - 16 = 2^16 = 65536 (6500 apps?)