# **27Mar2023 - Anypoint Platform Architecture: Integration Solutions**
###### tags: `MuleSoftTraining`
[TOC]
# Module 0: æºå
## Mimeoããæ¬¡ã®è³æã確èª
- :star: APAIntSols4.4_**studentFiles**_16nov2021.zip (åè¬è
ãã¡ã€ã«)
- APAIntSols4.4_studentSlides_16nov2021.zipã(åè¬è
ã¹ã©ã€ã)
- APAIntSol4.4_studentManual_JA_16nov2021.pdf(åè¬è
ããã¥ã¢ã«)
## ã¢ã«ãŠã³ããšãœãããŠã§ã¢ã®æºå
[ãã¡ã](https://salesforce.quip.com/bFrfAZE3riXy) ããåç
§ãã ããã
1. [Anypoint Platform ãã©ã€ã¢ã« (詊çš) ã¢ã«ãŠã³ã](https://salesforce.quip.com/QQN7Acqju0il)
2. [Anypoint Studio 7.14.0 (ææ°ç)](https://www.mulesoft.com/lp/dl/studio)
- ã³ãŒã¹éå§åã«ããŠã³ããŒããšã€ã³ã¹ããŒã«ãè¡ãããœããã®èµ·åãã詊ããã ããã
- ãããããšã©ãŒãšãã©ãã«ã·ã¥ãŒãã£ã³ã°ã¯[ãã¡ã](https://salesforce.quip.com/n2iFAKKHMM1A)ããã確èªãã ããã
3. [Mule Runtime 4.4 (ææ°ç)](https://www.mulesoft.com/lp/dl/mule-esb-enterprise)
4. [Advanced REST Client](http://install.advancedrestclient.com/install)
- [Postman] (https://www.postman.com/downloads/)ãªã©ãä»ã® REST API ã¯ã©ã€ã¢ã³ãã¢ããªã±ãŒã·ã§ã³ã䜿çšå¯èœã§ãã
5. [Java 8/11 (Adopt OpenJDK)](https://salesforce.quip.com/5B2PAV46QbB5)
- `java -version`
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`
- 泚1: [Node.js](https://nodejs.org/ja/download/) ã®ã€ã³ã¹ããŒã«ãå¿
èŠã«ãªããŸãã
- 泚2: [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) ã®ã€ã³ã¹ããŒã«ãå¿
èŠã«ãªããŸãã

9. [Apache Maven](https://dlcdn.apache.org/maven/maven-3/3.8.4/binaries/apache-maven-3.8.4-bin.zip)
- bin ãã£ã¬ã¯ããªã« Path ãéã
- `mvn -version`
## ãã£ã¬ã¯ããªã®æºå
- MuleSoft_Training_IntSol_07mar2022
- exportedApps
- installs
- performance
- resources
- :star: APAIntSols4.4_**studentFiles**_16nov2021.zip (åè¬è
ãã¡ã€ã«)
- APAIntSols4.4_studentSlides_16nov2021.zipã(åè¬è
ã¹ã©ã€ã)
- APAIntSol4.4_studentManual_JA_16nov2021.pdf(åè¬è
ããã¥ã¢ã«)
- workspace
- mule
- mule-4.4.0-node1
- mule-4.4.0-node2
- mule-ee-distribution-standalone-4.4.0.zip (äºå)
# Module 1: ã€ã³ãã°ã¬ãŒã·ã§ã³ãœãªã¥ãŒã·ã§ã³ã¢ãŒããã¯ãã£ã®ç޹ä»
## Catalyst Knowledgehub
catalyst.mulesoft.com (knowledgehub.mulesoft.com)
- [CloudHub Usecase](https://knowledgehub.mulesoft.com/s/article/CloudHub-Infrastructure-Use-Cases)
- æ¥æ¬èªã®è³æã
- https://knowledgehub.mulesoft.com/s/global-search/%40uri#q=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)

## 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: Anypoint Platform ã³ã³ããŒãã³ããšæ©èœã®çè§£
[Anypoint Platform ãã¹ãã£ã³ã°ãªãã·ã§ã³ã®æ¯èŒ](https://docs.mulesoft.com/jp/general/intro-platform-hosting)
## ã³ã³ãããŒã«ãã¬ãŒã³ vs ã©ã³ã¿ã€ã ãã¬ãŒã³
### ã³ã³ãããŒã«ãã¬ãŒã³
ã¢ããªã±ãŒã·ã§ã³ããMuleã©ã³ã¿ã€ã ã管çã»ç£èŠã»ãããã€ããããã®ã³ã³ããŒãã³ã矀
- :star: 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)

### ã©ã³ã¿ã€ã ãã¬ãŒã³
ã¢ããªã±ãŒã·ã§ã³ãMuleã©ã³ã¿ã€ã ã®ãããã€å
ãšãªããã¹ãã£ã³ã°ç°å¢
- :star: **CloudHub (MuleSoft-hosted)**
- MuleSoft ã管çãã AWS ç°å¢
- CloudHub ã¯ãŒã«ãŒ = EC2 ã€ã³ã¹ã¿ã³ã¹
- ã¯ã©ãŠãããŒã¹ã® key-value ãã¢ã¹ãã¬ãŒãž: Object Store v2
- ã¯ã©ãŠãããŒã¹ã®æ°žç¶å VM ãã¥ãŒ: Persistent Queue
- ã¹ã±ãŒãªã³ã°
- CHã¯ãŒã«ãŒã®æ°ãå¢ãã = ã¹ã±ãŒã«ã¢ãŠã
- CHã¯ãŒã«ãŒã®æ§èœãè¯ããã = ã¹ã±ãŒã«ã¢ãã
- [èªåã¹ã±ãŒãªã³ã°](https://docs.mulesoft.com/jp/runtime-manager/autoscaling-in-cloudhub) 㯠ELA å¥çŽã®ã¿
- ããŒããã©ã³ãµãŒ
- SLB(å
±æããŒããã©ã³ãµãŒ)
- HTTP 80 -> 8081
- HTTPS 443 -> 8082
- DLB(å°çšããŒããã©ã³ãµãŒ)
- HTTP 80 -> 8091
- HTTPS 443 -> 8092
- VPC ã«æ§æãã
- Customer-hosted Mule ã©ã³ã¿ã€ã
- ã¯ã©ã¹ã¿ãŒæ§æ / éã¯ã©ã¹ã¿ãŒæ§æ
- ãªã³ãã¬ãã¹
- VM
- ãã©ã€ããŒãã¯ã©ãŠã (AWS, Azure, GCP..)
- Runtime Fabric(RTFïŒã
- ã¯ã©ã¹ã¿ãŒæ§æ
- RTF-VM
- EC2 etc...
- RTF on self-managed k8s
- GKE, AKS, EKS etc...
Q. ã©ã³ã¿ã€ã ãã¬ãŒã³ã«äœãéžæãããã«ãã£ãŠãã©ã€ã»ã³ã¹ãéçšè²»çšã«å·®ã¯çããã®ã§ãããã?
- Hybrid / RTF > Platinum or Tatanium ã©ã€ã»ã³ã¹å¥çŽãå¿
èŠ
- https://www.mulesoft.com/anypoint-pricing
- ã©ã®å¥çŽã«ãããŠã Core æ°ã®æŠå¿µãããïŒOn-Premise Core vs Cloudhub vCoreïŒ
- https://help.mulesoft.com/s/article/How-to-Transfer-Mulesoft-on-Premise-Core-Licenses-to-Cloudhub-vCore-Licenses-or-Vice-Versa
- CloudHubïŒ 0.1 vCore, 0.2 vCore, 1 vCore...
- RTF: https://docs.mulesoft.com/jp/runtime-fabric/1.6/deploy-resource-allocation#vcpu-%E3%81%AE%E5%89%B2%E3%82%8A%E5%BD%93%E3%81%A6
- Customer-hosted Mule ã©ã³ã¿ã€ã : 1 Runtime - N apps
## Mule App
- JavaããŒã¹ã®ã¢ããªã±ãŒã·ã§ã³ãAnypoint Studioã§(ããŒã³ãŒã)éçºãå¯èœã
- XMLã§æ§æããã¢ããªã±ãŒã·ã§ã³ãMavenã䜿çšã㊠jar ã«ããã±ãŒãžã³ã°ããã
- 1ã€ã® Mule ã¢ããªã±ãŒã·ã§ã³ã¯ã1ã€ä»¥äžã®ãããŒã§æ§æãããã
## Flow
- 颿°ãã¡ãœããã®ããã«ãåå©çšå¯èœãªåäœã®ããžãã¯ã®å¡(ã¹ã³ãŒã)
- 颿°ã®ããã«ãåãåã£ããã€ã³ãããããããŸããŸãªããžãã¯ãçµãŠ(Transform Message ãªã©)ãã¢ãŠãããããšããŠãªã¿ãŒã³ããã
- ãããŒããå¥ã®ãããŒãåŒã³åºãããšãå¯èœ(Flow Reference)
## Mule 4 Event
Mule Event: Mule ã¢ããªã±ãŒã·ã§ã³ãæ±ãããŒã¿ãªããžã§ã¯ã(Javaãªããžã§ã¯ã)

- Mule Message
- Attributes (屿§ãã¡ã¿ããŒã¿)
- Headers
- Query Params
- etc...
- **Payload (ããŒã¿ã®æ¬äœ)**
- Variables (vars, 倿°)
- :warning: (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 ã«ã€ã³ããŒãããŠãåå°ãšãªãã¹ã±ã«ãã³ (ã€ã³ã¿ãã§ãŒã¹ãããŒ)ãèªåã§çæãã
- ApiKit
- Exchange ã«å
¬éããã¿ã€ãã³ã°ã§
- API ããŒã¿ã«ãèªåçæããã
- 仿§ãããšã«ããã¥ã¡ã³ããèªåçæãããŸã
- API ã³ã³ãœãŒã«ãèªåçæããã
- Anypoint Studioã§ãåç
§å¯èœ
- ã³ãã¯ã¿ã®èªåçæ (REST Connect)
- ã¢ããã³ã°ãµãŒãã¹ãèªåçæããã (ãããã¿ã€ã)
- [ã·ãã¥ã¬ãŒã·ã§ã³ããããŒ](https://docs.mulesoft.com/jp/design-center/apid-behavioral-headers)æ©èœã§ãããå®éã«è¿ãã¢ãã¯åŒã³åºããå¯èœ
- MS2-Delay
- MS2-Example
- MS2-Error-Rate

Q. ããã©ã«ãã®ã¢ããã³ã°ãµãŒãã¹ã®URLã ãšå€éšãããµãŒãã¹ããåŒã³åºãURLã¯ã©ã®ããã«çºè¡ããã®ã§ããããïŒCurlã§URLãå©ããšã{"errorType":"ServiceError","message":"No OrganizationId Header"}ããšã§ãŠããŸããŸãã
- èšå®+éçã¢ã€ã³ã³ > Make Publicãæå¹ã«ããŸããæå¹æéãèšå®ããããšãå¯èœã§ãã

## Semantic Versioning

Node.js
- Devlopment: 奿°ããŒãžã§ã³
- Stable: å¶æ°ããŒãžã§ã³
Major version . Minor version . Patch version - https://semver.org/lang/ja/
**2**.2.1 vs **3**.0.0(ãã¬ãŒãã³ã°ãã§ã³ãž->åŸæ¹äºææ§ãä¿ãŠãªã倿Ž)
1.**0**.0 vs 1.**1**.0(æ©èœè¿œå )
2.2.**1** vs 2.2.**2**(ãã°ä¿®æ£)
## API ã®ç®¡çã»ä¿è·

### Basic Endpoint(åã蟌ã¿å)

+ã¢ããªã±ãŒã·ã§ã³ã®æ°ãæãããã
+vCoreã®æ¶è²»ãæãããã($$$)
+远å ã®ãããã¯ãŒã¯ãããããªã=远å ã®ã¬ã€ãã³ã·ãŒããªã
-Studio ã§ã®äœæ¥ãå¿
èŠïŒautodiscovery ID ã®èšå®ïŒ
-Mule ã¢ããªã±ãŒã·ã§ã³ããä¿è·ã§ããªã
### Endpoint with Proxy(APIãããã·ã¢ããªã±ãŒã·ã§ã³å)

+Non Mule ã¢ããªã±ãŒã·ã§ã³ã®ä¿è·
+Studio ã§ã®äœæ¥ãäžèŠ
+APIãããã·ãšAPIå®è£
ã®æç¢ºãªåé¢
+è€æ°ã®APIãããã·ã§ã1ã€ã®å®è£
ãä¿è·ããããšã«ãããã³ã³ã·ã¥ãŒããŒ/ã¯ã©ã€ã¢ã³ãããšã«é©çšããããªã·ãŒãå€ãã
-URLãè€æ°ãã (APIãããã·+APIå®è£
) = è€é
-ã¢ããªã±ãŒã·ã§ã³ã®æ°ãå¢ããŠããŸã
-vCoreãæ¶è²»ããŠããŸã($$$)
-ãããã¯ãŒã¯ã®ããããå¢ãã->ã¬ã€ãã³ã·ãŒã®å¢å (?)
### [Service Mesh](https://docs.mulesoft.com/jp/service-mesh/1.1/)
[what is service mesh](https://www.mulesoft.com/resources/api/what-is-a-service-mesh)


Q.Service Mesh ã§ã¯ã³ã¢ãæ¶è²»ããã?

Yes, ã³ã¢ãæ¶è²»ããŸãã管çãã API ã®ãµã€ãºã«ãã£ãŠãã³ã¢ã®ãµã€ãºã¯å€ãããŸãã
## [Flex Gateway](https://www.mulesoft.com/platform/api/flex-api-gateway)
> Anypoint Flex Gateway is ultrafast, designed to manage and secure APIs running anywhere. Built to integrate seamlessly with DevOps and CI/CD workflows, Anypoint Flex Gateway delivers the performance required for the most demanding applications while providing enterprise security and manageability across any environment.
- [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. åã蟌ã¿åã®å Žåããããã€å
ã«ãã£ãŠããªã·ãŒã®çްããæ¡ä»¶ãå€ããå ŽåãStudioã§æ¯å倿Žããå¿
èŠããããšãèªèã§ããã§ãã?Sandboxãšæ¬çªã§å€ãããªã©ãæ³å®ããŠããŸãã
- ç°ãªãç°å¢ã§ã®APIã®ç®¡çã¯ãç°ãªãAPIã€ã³ã¹ã¿ã³ã¹ãæ§æã§ããŸã(=ç°ãªãautodicovery IDãçæããã)

- autodiscovery IDã¯ããã¬ãŒã¹ãã«ããŒïŒ${}ïŒã䜿çšããããšã§ããããã€ã®ã¿ã€ãã³ã°ã§åçã«åãæ¿ããããšãå¯èœã§ãã


# Module 3: Mule ã¢ããªã±ãŒã·ã§ã³ã䜿çšããã€ã³ãã°ã¬ãŒã·ã§ã³ãœãªã¥ãŒã·ã§ã³ã®èšèš
## ãããŒã®åŠç
å·Šããå³ãž(ã³ãŒãã®äžããäžãž) **åæç**ã«åŠçãè¡ã
## éåæã®åŠçãè¡ãããã»ããµã»ã¹ã³ãŒãã»ã³ãã¯ã¿ã®äŸ
- Async ã¹ã³ãŒã
- Scatter-Gatherãã«ãŒã¿ãŒ
- VM ã³ãã¯ã¿
- JMS ã³ãã¯ã¿
- Logger -> ããã©ã«ã㯠Async Logger
- Batch Job
- Parallel For Each
- etc..
## Mule SDK > ã³ãã¯ã¿ã»ã¢ãžã¥ãŒã«ã®éçº
https://docs.mulesoft.com/jp/mule-sdk/1.1/
- Java SDK
- XML SDK
- RAML ã OAS ããã³ãã¯ã¿ãèªåçæãããREST Connect ã«ã䜿çšããã
### mule-db-connector
https://github.com/mulesoft/mule-db-connector
## Maven3ã®å§ãæ¹
https://maven3.kengo-toda.jp/
## Exchange: stable vs development
- stable
- å®å®ç
- API Manager ã§ã®ç®¡çããAnypoint Studioã§ã®éçºãå¯èœ
- developlemt
- éçºäž
- deprecated
- éæšå¥š

## REST Connect ã³ãã¯ã¿ã®äœ¿çš
displayNameã倿Žããããšã§ãããçŽæçãªè¡šç€ºåã«ããããšãã§ãã(æ¥æ¬èªãå¯èœ)

åŒã³åºãå
ã®èšå®


## APIKit
RAMLããåå°ãšãªãã¹ã±ã«ãã³ãããŒãããªããŒã·ã§ã³ãèªåã§çæããããã®ããŒã«ãAPI Consoleãèªåçæãããã
- API Consoleãããããšã«ãã£ãŠãAPIã®ãã¹ãåŒã³åºããç°¡çŽ åããã(ARCãªãã§ããã¹ããå¯èœ)
-ã仿§ã»ããã¥ã¡ã³ãã®ç¢ºèªãå¯èœ
## Rest Connect ã³ãã¯ã¿
- RAMLããèªåçæãããã³ãã¯ã¿ãExchangeã«å
¬éãããã¿ã€ãã³ã°ã§çæãããã
- ãã©ã¡ãŒã¿ããªãœãŒã¹åãã¡ãœãããèªèšŒæ
å ±ãªã©APIåŒã³åºãã«ããããè€éããã³ãã¯ã¿ã«é èœãã
## ãã¡ã€ã³ãããžã§ã¯ã
Customer-hosted Muleã©ã³ã¿ã€ã ã®ã¿ã§æ§æå¯èœ

## Scheduler ã®æå

- CloudHub
- è€æ°ã®ã¯ãŒã«ãŒããã£ãŠãã ã©ã¡ããã¯ãŒã«ãŒã§å®è¡
- CloudHub ã§ã¯ "1"
- Cron 㯠**UTC** ã®ã¿ã€ã ãŸãŒã³ã䜿çšãã
- ã¹ã¿ã³ãã¢ããŒã³ & RTF
- Clusteræ§æããšã£ãŠããªãå Žå
- ããããã®ããŒãã§ Scheduler ãå®è¡
- Clusteræ§æããšã£ãŠããå Žå
- 1ã€ã®ããŒãã§å®è¡ããã (= primary ããŒã)
## DataWeave
- [Playground Library](https://developer.mulesoft.com/learn/dataweave/)
```
%dw 2.0 // dw ã®ããŒãžã§ã³ çç¥å¯èœ
output application/csv header=false,separator="\t"
// åºåããŒã¿å -> output jsonã§ãOK
// https://docs.mulesoft.com/dataweave/2.4/dataweave-formats-csv#reader_properties
---
// String, Number, Boolean, Null, Date
// Object, Array
/**
* output application/xml
* xml ã¯èŠªã¿ã°ãå¿
èŠãé
åã () ã§å²ãã§å®£èšããã
* parentTag:{([{
* hello:"world"
* },
* {
* hello:"world2"
* }])
* }
*/
[{
hello:"world",
hello2:"worldX"
},
{
hello:"world2",
hello2:"worldY"
}]
```
## Error Handler
### Error Handlerã¹ã³ãŒã
https://docs.mulesoft.com/jp/mule-runtime/4.4/error-handling
0. **Mule**ããã©ã«ããšã©ãŒãã³ãã©ãŒ
- *ã«ã¹ã¿ãã€ãº*ãªã©ã¯äžå¯
- æ±çšçã«åŠç (Propagate)
1. ã¢ããªã±ãŒã·ã§ã³/ã°ããŒãã«ãšã©ãŒãã³ãã©

- åå¥ã®ãšã©ãŒãã³ãã©ãŒ(2.ãããŒ, 3.Tryã¹ã³ãŒã/ããã»ããµ)ãèšå®ãããŠããªããšãã ãããã®ãã³ãã©ãŒã§åŠçãããã
- Global Elements > Create > Configuration > Default Error Handler ã§èšå®
**Default** ã¯ãã¢ããªã±ãŒã·ã§ã³ã®ããã©ã«ã(=Application/Global Error Handler)ã®æå³ã§ãããã0.Mule ããã©ã«ããšã©ãŒãã³ãã©ãŒ(ã«ã¹ã¿ãã€ãºäžå¯)ãã®ããšã§ã¯ãªã

2. ãããŒã¬ãã«ãšã©ãŒãã³ãã©

3. Try/ããã»ããµã¬ãã«ãšã©ãŒãã³ãã©

### Error Handler ã®çš®é¡
1. On Error Propagate
- ããã©ã«ãã®åŠç(**Mule**ããã©ã«ããšã©ãŒãã³ãã©ã§äœ¿çš)
- "ãšã©ãŒããšã©ãŒ"ãšããŠåŠç
- ãšã©ãŒãªããžã§ã¯ããäŒæããŠãåŒã³åºãå
ã«äŒãã
- ãšã©ãŒã Continue åŠçãããšãTransactionã¯ããŒã«ããã¯ããã
2. On Error Continue
- ãŸãã§"ãšã©ãŒãèµ·ããŠããªããã®ããã«"åŠç
- èªåã®ãšã©ãŒãä»ã®åŠçã«åœ±é¿ããªãããã«ã"ãšã©ãŒã飲ã¿èŸŒã"
- ãšã©ãŒãèµ·ããŠãä»ã®åŠçãç¶ç¶ãã (=continute)
- ãšã©ãŒã Continue åŠçãããšãTransactionã¯ã³ãããããã

## ã«ãŒã¿ãŒ
### 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(BlockingïŒ
```
@Execution(CPU_INTENSIVE)
public void computeFlightPlan() {
...
}
```
## DEDICATED: Mule 4.1, 4.2
3ã€ã®å®è¡ã¢ãã«ããšã«ãå¥ã
ã®ã¹ã¬ããããŒã«ãçšæãããŠããã(CPU_LITE, CPU_INTENSIVE, **IO_INTENSIVE**)
scheduler-pool.conf
IO_INTENSIVE(Blocking) `maxSize=max(2, cores + ((mem - 245760) / 5120))`
```
# 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 `size=2*cores`
```
# 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 `size=2*cores`
```
# 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+
`org.mule.runtime.scheduler.threadPool.strategy=UBER`

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))
```
## mule ã©ã³ã¿ã€ã ã®èµ·å
bin ãã£ã¬ã¯ããªã§
Mac: `./mule`
Windows: `mule.bat`
## mule ã©ã³ã¿ã€ã ã®åæ¢
https://docs.mulesoft.com/jp/mule-runtime/4.4/starting-and-stopping-mule-esb#mule-%E3%81%AE%E5%81%9C%E6%AD%A2
bin ãã£ã¬ã¯ããªã§
Mac: `./mule stop`
Windows: `mule.bat stop`
## Tanuki Wrapper
https://wrapper.tanukisoftware.com/doc/japanese/introduction.html
> Wrapper ã¯ãJVM ããã»ã¹ãã¢ãã¿ãªã³ã°ïŒç£èŠïŒãã ãã JVM ãã¯ã©ãã·ã¥ãããããã³ã°ã¢ããããæã«ã¯ãèªåçã«åèµ·åãããŸãã ãã®åŠçã¯ãWrapper ããåé¡ãããããšå€æããå Žåã«å®è¡ãããæèŠæéã¯ã»ãã®æ°ç§ã§ãã ããã«ãJVM ã®ã³ã³ãœãŒã«åºåãã¢ãã¿ãªã³ã°ïŒç£èŠïŒããŠã ããäžé£ã®æååã«åå¿ããŠãJVM ãåèµ·åãããã·ã£ããããŠã³ããããã«ãWrapper ã®èšå®ã倿Žããããšãã§ããŸãã

```
# Initial Java Heap Size (in MB)
wrapper.java.initmemory=1024
# Maximum Java Heap Size (in MB)
wrapper.java.maxmemory=1024
```
Q. visualVM - Cannot find Java 1.8 or Higher
https://github.com/oracle/visualvm/issues/112
It works.
`visualvm.exe --jdkhome "C:\Program Files\AdoptOpenJDK\jdk-8.0.242.08-hotspot"`
`visualvm.exe --jdkhome "C:/Program Files/AdoptOpenJDK/jdk-8.0.242.08-hotspot"`
`visualvm.exe --jdkhome "C:/Program Files/AdoptOpenJDK/jdk-8.0.242.08-hotspot/"`
It does not work...
`visualvm.exe --jdkhome "C:\Program Files\AdoptOpenJDK\jdk-8.0.242.08-hotspot\"`
## Runtime Manager Agent
Mac: `./amc_setup -H 9910f194-0c5c-4e86-9a44-aa9094116f64---662992 node1`
Windows: `./amc_setup -H 9910f194-0c5c-4e86-9a44-aa9094116f64---662992 node1`
Q. Runtime Manager Agentã®Proxy èšå®
https://docs.mulesoft.com/jp/runtime-manager/rtm-agent-proxy-config#mule-agent-yml-%E3%82%92%E4%BD%9C%E6%88%90%E3%81%99%E3%82%8B%E3%81%9F%E3%82%81%E3%81%AE-amc_setup-%E3%81%AE%E5%AE%9F%E8%A1%8C
`-P proxy-host proxy-port proxy-user proxy-password`
## ã¬ã³ãŒãã®åŠç
- 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
```
- Parallel For Each
- ãã«ãã¹ã¬ãã
- éåæåŠç
- åã¬ã³ãŒãã®å€ã倿Žå¯èœ
```
INFO 2022-02-02 13:33:57,974 [[MuleRuntime].uber.06: [mod04-foreach_pararrelforeach_batchjob].parallelForEach.CPU_LITE @1e52b5e4] [processor: parallelForEach/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].parallelForEach.CPU_LITE @1e52b5e4] [processor: parallelForEach/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].parallelForEach.CPU_LITE @1e52b5e4] [processor: parallelForEach/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].parallelForEach.CPU_LITE @1e52b5e4] [processor: parallelForEach/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].parallelForEach.CPU_LITE @1e52b5e4] [processor: parallelForEach/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].parallelForEach.CPU_LITE @1e52b5e4] [processor: parallelForEach/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].parallelForEach.CPU_LITE @1e52b5e4] [processor: parallelForEach/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].parallelForEach.CPU_LITE @1e52b5e4] [processor: parallelForEach/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].parallelForEach.CPU_LITE @1e52b5e4] [processor: parallelForEach/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].parallelForEach.CPU_LITE @1e52b5e4] [processor: parallelForEach/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"
}
```
## ãšã¯ãµãµã€ãº 4-2ïŒ MySQLãšSaaSã·ã¹ãã ã®åæ

- MySQL ããŒã¿ããŒã¹ã SaaS CRM ã·ã¹ãã ãšåæãããå¿
èŠããã
- CRM ã·ã¹ãã ã¯ã§ããã ãæ©ãæŽæ°ããªããã°ãªããªã
- ãã®ã€ã³ãã°ã¬ãŒã·ã§ã³ã§ã¯ãåã¬ã³ãŒãã®ç£æ»ãšè¿œè·¡ããµããŒãããå¿
èŠããã
- 倱æããã¬ã³ãŒãã®åŸåŠçãè¡ããããã«ã人ãæäœã§ããããã«ããŠããå¿
èŠããã
- Mule ã¢ããªã±ãŒã·ã§ã³ã¯ãåäžã® 0.2 vCore CloudHub ã¯ãŒã«ãŒãžã®ãããã€ãæ³å®ããŠèšèšãããŠãã (1 GB ã®ããŒãã¡ã¢ãªïŒ
1. On Table Row(DBã³ãã¯ã¿)
- èªåã®ãŠã©ãŒã¿ãŒããŒã¯èšå®
- Transform Messageã§salesforceã«ããŒã¿ãå
¥ããåæºåãè¡ã
- Salesforce ã³ãã¯ã¿
- Error Handler?
2. Scheduler
- Object Storeã§ãŠã©ãŒã¿ãŒããŒã¯ãèšå®/ååŸ
- DBã³ãã¯ã¿ > Select
- Batch Job
- Batch Aggregator ã§äžæ¬åŠç(Salesforce ã³ãã¯ã¿)
- 倱æããåŠççšã®Batch Stepã䜿çšããŠãDLQãã¥ãŒã«è©°ã蟌ã
3. ããŒã¿ããŒã¹æŽæ°æã«æŽæ°ã¬ã³ãŒããRESTã§ãããšããã¥ãŒã«æ ŒçŽããã
ãã¥ãŒããåãåºããªããCRMã«é£æº
## ãšã¯ãµãµã€ãº 4-3ïŒäžæ¹å (one-way) ã®ãã¡ã€ã«è»¢éãŠãŒã¹ã±ãŒã¹ã«é©ãã Mule ã€ãã³ãåŠçãèšèšãã

- 1æ¥ã«äœåãã©ã³ãã ã«ã顧客ã®è²¡åããŒã¿ãå«ãŸããæ°ãããœãŒã¹ãã¡ã€ã«ãããã¡ã€ã«ãµãŒããŒäžã®ç¹å®ã®ãã£ã¬ã¯ããªã«ã¢ããããŒããã
- Mule ã¢ããªã±ãŒã·ã§ã³ã¯ããã«ãã¡ã€ã«ãåŠçããã¿ãŒã²ããã® MySQL ããŒã¿ããŒã¹ã«çµæãéä¿¡ããå¿
èŠããã
- åãã¡ã€ã«ã«çŽ100äžä»¶ã®é¡§å®¢ããŒã¿ã¬ã³ãŒããå«ãŸããŠãã
- åã¬ã³ãŒãã®ç£æ»ãšè¿œè·¡æ©èœãäžå¯æ¬
- 倱æããã¬ã³ãŒãã®åŸããåŠçãè¡ããããã«ã人ãæäœã§ããããã«ããŠããå¿
èŠããã
- Mule ã¢ããªã±ãŒã·ã§ã³ã¯ åäžã® 0.2 vCore CloudHubã¯ãŒã«ãŒãžã®ãããã€ãæ³å®ããŠèšèšãããŠãã(1 GBã®ããŒãã¡ã¢ãªãŒ)
1. On New Updated File
- For Each
- Queue
- Queue ããåãåºããŠåŠç
2. On New Updated File
- Batch Job
- Batch Jobã®èªã¿èŸŒã¿ãã§ãŒãºã§ãšã©ãŒãçºçããªããã確èªããã¡ã€ã«ãåå²ïŒe.g ïŒïŒïŒ,000*5ïŒããå¿
èŠãããå¯èœæ§ã
- ãšã©ãŒå°çšã®Batch Step + Queue
3.ãOn New Updated File
- For Each(batch sizeãèšå®)
- ããã©ã«ãã®1ã§100äžä»¶ãåŠçããã®ã¯å³ããã?
- DBã³ãã¯ã¿ã®Bulk Insert
- Error Handler
4.ãOn New Updated File
- Parallel For Each
- Error Handler
# Module 5: é©åãªã¡ãã»ãŒãžãã©ã³ã¹ãã©ãŒã¡ãŒã·ã§ã³(倿)ãšã«ãŒãã£ã³ã°ãã¿ãŒã³ã®éžæ
DataSenseãã¡ã¿ããŒã¿ã®èªã¿èŸŒã¿ãšå€æããµããŒã

## ããŒã¿å€æã®è€éæ§ : Common Data Model (å
±æããŒã¿ã¢ãã«) ã®æå¹æŽ»çš
- N\*N(-1) => **O(N^2)**
N=6 6Ã5 -> 30
N=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/PAPIïŒãããã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)
# Module 6: Mule ã¢ããªã±ãŒã·ã§ã³ã®ãã¹ãæŠç¥ã®èšèš
> Untested code is broken code.
## MUnit ãã¹ã
### ãšã©ãŒãåºãå Žå
Xml -> ãã¹ãåãã¯ãªãã¯ããŠã詳现ãªãšã©ãŒã衚瀺ããã

### 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
# Module 7: ãããã€ã¡ã³ãæŠç¥ã®æ±ºå®ãšéçº
## CloudHub ãŒãããŠã³ã¿ã€ã ã®ãããã€

## VisualVMã§ã¹ã¿ã³ãã¢ããŒã³Muleã©ã³ã¿ã€ã ã®ã¡ã¢ãªã®å€åã確èªãã
193è¡ç® default => 1024ã
ããã§ã¯ã¡ã¢ãªã®æå°ã倿Ž
`wrapper.java.initmemory=512`
197è¡ç® default => 1024ã
ããã§ã¯ã¡ã¢ãªã®æå€§ã倿Ž
`wrapper.java.maxmemory=512`
- ããã»ã¹ã確èª
ãã§ãã¯ãã€ã³ã: ã¡ã¢ãªã¯ 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
- ã©ã³ã¿ã€ã ãã¬ãŒã³: ã¹ã¿ã³ãã¢ããŒã³ïŒRTFã¯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)
# Module 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 ã®äœ¿çšãæ€èš
Object Store ã¯ããŒããªã¥ãŒãã¢
```
{
"persistent": "cloudHubValue"
}
```
- Store Object Store V2
- ãšã³ããã€ã³ã: /object-store/**storePersistent**?key=**persistent**&value=cloudHubValue
- Retrieve ObjetStore V2
- ãšã³ããã€ã³ã: /object-store/**retrievePersistent**?key=**persistent**
retuens `"cloudHubValue"`
- Store NP (Non Persistent: éæ°žç¶çãª) ObjetStore
- ãšã³ããã€ã³ã: /object-store/**storeNonPersistent**?key=**nonPersisten**t&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`
https://docs.mulesoft.com/jp/mule-runtime/4.4/mule-high-availability-ha-clusters#%E3%83%91%E3%83%95%E3%82%A9%E3%83%BC%E3%83%9E%E3%83%B3%E3%82%B9%E3%83%97%E3%83%AD%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB%E3%81%AE%E8%A8%AD%E5%AE%9A
> Unicast servers must be in the Running state.
Unicastã§å®è¡ããå Žåã¯ããŸãmuleã©ã³ã¿ã€ã ãå®è¡ãã
1. .mule/mule-cluster.propertiesãåé€
2. ã©ã³ã¿ã€ã ãèµ·åãã
Mac
- ./mule -M-Dhttp.port=9081
- ./mule -M-Dhttp.port=9082
Windows:
- mule.bat -M-Dhttp.port=9081
- mule.bat -M-Dhttp.port=9082
3. Unicastã§ãäºããæ€ç¥ããã


https://help.mulesoft.com/s/article/Unicast-Cluster-shows-Communication-Issues-Detected

4. ãã¹ãïŒ
## stateful-playground.jar(cluster)
- 1.Store Persistent
- http://localhost:**9081**/object-store/storePersistent?key=persistent&value=Cluster-persistent!
- 2.Retrieve Persistent
- http://localhost:**9081**/object-store/retrievePersistent?key=persistent
- http://localhost:**9082**/object-store/retrievePersistent?key=persistent
- `Cluster-persistent!`
- è€è£œããããŠãã!
- 3.Store Non Persistent (éæ°žç¶ç)
- http://localhost:9082/object-store/storeNonPersistent?key=nonPersistent&value=Cluster-non-persistent!
- 4.Retrieve NonPersistent(éæ°žç¶ç)
- http://localhost:9082/object-store/retrieveNonPersistent?key=nonPersistent
- http://localhost:9081/object-store/retrieveNonPersistent?key=nonPersistent
- `Cluster-non-persistent!`
- è€è£œããããŠãã!
- 5. åèµ·ååŸã®æåã確èªãã: å
šãŠã®å€ãåèµ·ååŸãååŸå¯èœ(HZ IMDGã§è€è£œæžã¿)
- http://localhost:**9081**/object-store/retrieveNonPersistent?key=nonPersistent
- http://localhost:**9082**/object-store/retrieveNonPersistent?key=nonPersistent
- http://localhost:**9081**/object-store/retrievePersistent?key=persistent
- http://localhost:**9082**/object-store/retrievePersistent?key=persistent
6. primary nodeã¯å€æŽããã

- JMS: primary node only
https://docs.mulesoft.com/jms-connector/1.8/jms-performance#cluster-configuration-optimization
- Schedulerã¯primary nodeã®ã¿ã§åã
non primary node

primary node

## ã¹ã¿ã³ãã¢ããŒã³ã©ã³ã¿ã€ã Object Store
- persistent(æ°žç¶ç)
- .mule > <appname> > objectstore ã«ä¿åãããŠãã
- transient(äžæç)
- ã¡ã¢ãª
### stateful-playground.jar(ã¹ã¿ã³ãã¢ããŒã³)
- 1.Store Persistent
- http://localhost:8081/object-store/storePersistent?key=persistent&value=Standalone!
- 2.Retrieve Persistent
- http://localhost:8081/object-store/retrievePersistent?key=persistent
`Standalone!`
- 3.Store Non Persistent (éæ°žç¶ç)
- http://localhost:8081/object-store/storeNonPersistent?key=nonPersistent&value=Standalone!
- 4.Retrieve NonPersistent(éæ°žç¶ç)
- http://localhost:8081/object-store/retrieveNonPersistent?key=nonPersistent
`Standalone!`
- [x] åèµ·ååŸã ã¹ã¿ã³ãã¢ããŒã³ã® 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ãå
±æå¯èœã«ããããšãã§ãã
# Module 9: 广çãªãã°ãšç£èŠ(ã¢ãã¿ãªã³ã°)ã®èšèš
## CloudHub log
100MB or 30 days
https://docs.mulesoft.com/runtime-manager/custom-log-appender#create-your-log4j-configuration
## Anyoint Monitoring 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.
## JMeter + Proxyã®èµ·åæ¹æ³ ãŸãšãã
`.\jmeter.bat -H proxyHost -P proxyPort`
# Module 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`
â» ã¹ããŒã¹ãããå Žåã¯""ã§å²ã(`--organization="MuleSoft Training"`)
â» !ãªã©ãããå Žåã¯ã`\`ã§ãšã¹ã±ãŒã
`--password=\!MuleSoft2020`
äŸ: Runtime Manager ã¢ã©ãŒãã®äžèЧãååŸ
`runtime-mgr cloudhub-alert list`
äŸ: Runtimeã®ãµãŒããŒã®ååã倿Ž
`runtime-mgr server list` // ID ãååŸ
`runtime-mgr server describe 13634800`ã// 詳现æ
å ±ã®è¡šç€º
`runtime-mgr server modify 13634800 --name nodex` // node1 -> nodex
2. ã¹ã¯ãªããã£ã³ã°ã¢ãŒã
## Anypoint Platform API
### Anypoint Platform 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.
> Should an API Rate Limit be exceeded, the Anypoint Platform will reject requests with a 503 Service Unavailable or 503 Service Temporarily Unavailable HTTP Response Code.
## Anypoint Platform REST API ã®åŒã³åºãæ¹
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 ãåŒã³åºãããšãå¯èœã«ãªããŸãã
äŸ: `Authorization: bearer 80566d46-3827-463c-b624-c36bae02d0df`

Access Managent API `https://anypoint.mulesoft.com/accounts/api/me`
[Anypoint Platform API](https://anypoint.mulesoft.com/exchange/portals/anypoint-platform/)
â» curl: `curl -X POST https://anypoint.mulesoft.com/accounts/login -H "Content-Type: application/json" -d '{"username":"asakaguchi_training_07mar2022", "password":"!MuleSoft2020"}`
â» Postman ã®ã¯ãããŒã®åé€
postman ã®sendãã¿ã³ã®äžã«cookieãç·šéããæ©èœããããŸããããã¡ãã§ã¯ãããŒæ¶ããŠåºæ¥ãŸããã
### Access Managemnt API
https://anypoint.mulesoft.com/accounts/api/users/me
# Module 11: Mule ã¢ããªã±ãŒã·ã§ã³ã«ããããã©ã³ã¶ã¯ã·ã§ã³(TX)ã管çèšèš
â» TX = ãã©ã³ã¶ã¯ã·ã§ã³
ãã¹ãŠã®ã¡ãã»ãŒãžåŠçã¯åäžã¹ã¬ããã§è¡ã
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
åäžã®ããŒã¿ãœãŒã¹ã§å®è¡ãããã©ã³ã¶ã¯ã·ã§ã³(e.g åäžDBã®åäžããŒãã«)
## XA TX
è€æ°ã®ããŒã¿ãœãŒã¹ãè·šãã ãã©ã³ã¶ã¯ã·ã§ã³
bitronix XA ãããžã£ãŒ
<bti:transaction-manager doc:name="Bitronix Transaction Manager" doc:id="15009545-b62f-4210-972d-df654f3a5f6c" />
## XA ãã©ã³ã¶ã¯ã·ã§ã³ãã³ãºãªã³ã®åŒã³åºãäŸ
`/init` -> 2ã€ããŒãã«ãäœæ(orders, orders2)
`/drop` -> ããŒãã«ããããã
`/select` -> ã»ã¬ã¯ã
`/doStuffAsXA?id=1&haveError=false&customerName=MaxMule`
-> ãšã©ãŒãªã XA TX
`/doStuffWithoutTransaction?id=2&haveError=false&customerName=MaxineMule`
-> ãšã©ãŒãªã
`/doStuffAsXA?id=3&haveError=true&customerName=MaxMule`
-> ãšã©ãŒãã ãã©ã³ã¶ã¯ã·ã§ã³ãã
`/doStuffWithoutTransaction?id=4&haveError=true&customerName=MaxineMule`
-> ãšã©ãŒãã ãã©ã³ã¶ã¯ã·ã§ã³ãªã
#### 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 (éè€ã®å¯èœæ§)
# Module 12: ä¿¡é Œæ§(reliability)ç®æšã«åããèšèš
## Reliablity Pattern
- åæ¥ç¶æŠç¥
- åããªããªãŒããªã·ãŒ(ã¡ãã»ãŒãž)
- Transaction(LocalTX/XATX)
- ãšã©ãŒåŠç
- First Successful
### Messaging Queue

### Until Successful
Until Successful + Try + On Error Continueã§ãããšã©ãŒã®çš®é¡ã«å¿ããŠããªãã©ã€ãããã©ãããã倿ãã(4XXç³»ã®ãšã©ãŒã§ããã°ãOnErrorContinueã§Until Successfulããæãåºãããªã©)
- On Error Continue ã¯ãšã©ãŒã飲ã¿èŸŒããããSuccessããããšå€æãããããšãã§ãã
