Академический Документы
Профессиональный Документы
Культура Документы
com
Email : ameerg.eai@gmail.com
Ameer Basha
MuleSoft Development – Best Practices & Naming Conventions
Introduction
Given the importance and value that APIs represent for numerous businesses, it’s important to consider
API development best practices when designing and building APIs using MuleSoft. The APIs that have
the most value and use for the enterprise are more like products than code. They are designed to be
consumed by specific audiences (e.g., mobile developers), they are well-documented, and they are
versioned so users can have certain expectations of the API maintenance and lifecycle. API development
best practices enable the full API lifecycle from design, build, test, through to deployment.
Overview
Anypoint Studio
Studio updates
➢ Keep your Anypoint Studio up-to-date (Install Studio Updates when available)
Mule Runtime
➢ It’s really important the coherence of the Mule Runtimes version within the SDLC. If you
developed and tested your application using a Mule Runtime 3.9.0, deploy it to a worker with
the same Runtime version.
➢ Upgrade your projects constantly to the latest patch-version 3.9.x/4.0.x/4.1.x (Install the new
Runtimes from the Studio Update Site or from the Mule Runtime Update Site).
➢ If you want to migrate your applications to a minor-new-version or a major-new-version (e.g.
3.9.x or 4.x) follow the migration guides provided in the MuleSoft public documentation
https://docs.mulesoft.com/release-notes/
➢ Define a line width in your Anypoint Studio XML editor preferences, e.g. 140
➢ Indent all your xml (mule xmls, pom.xml, log4j2.xml, etc) files before committing to the
source code repository
Mule Components
Dataweave
➢ ${http.private.port} when deploying to CloudHub using HTTP and using a Dedicated Load
Balancer (http.private.port is a reserved key in CloudHub that resolves to 8091)
➢ ${https.private.port} when deploying to CloudHub using HTTPS and using a Dedicated Load
Balancer (https.private.port is a reserved key in CloudHub that resolves to 8092)
If HTTPS is required (e.g. in the DLB upstream protocol or for the CloudHub shared load balancer) use
the HTTP Listener with a TLS Context reference, configuring the key-store with a key-pair values
generated with keytool.
HTTP Request
Database Connector
APIKit
Validator
Flows Reusability
➢ Use Flow references to separate and reuse common logic. The flow diagram should be clear,
showing the steps of the use case.
SSL
➢ Always use HTTPS listeners, if your applications are exposed on the internet or if you have
internal security regulations. HTTPS can also be terminated at load balancer level when using
Dedicated Load Balancer or where the user is hosting their own load balancer on-premises.
➢ In NYU, there is a Dedicated Load Balancer configured. HTTPS in listener in Mule applications
is not mandatory because the SSL termination is done on the DLB.
➢ Sensitive application properties such as access credentials and passwords can be obfuscated
in CloudHub by using the Secure Application Properties feature.
➢ Such feature can be used in conjunction with the Mule Credentials Vault that allows users to
encrypt properties within the application properties files.
o Use AES algorithm with a CBC mode.
Cache
➢ Use the Cache scope whenever possible, to wrap HTTP calls / flows / logic that
obtain/produce information that doesn’t change frequently
➢ Define a ttl (time to live) based on an analysis, it shouldn’t be arbitrary
Wire Logging
To enable a more detailed logging to see all the HTTP requests and responses, configure the following
loggers in src/main/resources/log4j2.xml
Naming Conventions
packages
{dw}_{classifier}
dw.customers.accounts
dw.health_check
Conclusion
In this article, I have provided some basic MuleSoft coding standards and namining standards. There is
no such thing as a naming convention for Mule. You could try to apply the same rules Mule community
developers follow, but those are not strictly for Mule Applications.
At the same time it does make sense to follow the same naming conventions than the IoC container of
Spring given that Mule is a sort of specialization of it. Organization to Organization these standards
changes.
Download
S. No File Name Size Download
1 MuleSoft Development – Best Practices & Naming Conventions.pdf 1.0 MB Download