- Notifications
You must be signed in to change notification settings - Fork3
A 'Bootiful' approach to run Mule 4 embedded into a Spring Boot application.
License
hawkore/mule4-spring-boot-starter
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
A 'Bootiful' approach to run Mule 4 embedded into a Spring Boot application.
The goal of this starter is to join Mule's productivity with the Spring Boot ecosystem.
This will allow you to build highly productive and easily scalable systems with very interesting features:
- Mule Runtime monitoring withSpring Boot Admin:
- Easy loglevel management
- Follow and download logfile
- JVM & memory metrics
- Interact with JMX-beans
- Show health status
- ...
- Manage Mule artifacts (applications/domains), exposing Mule deployment services through Spring Boot REST controllers, as a stand-alone instance.
- Easy deployment of Mule applications as micro-services on Kubernetes or another container management platform.
- Deploy Mule artifacts stored in anexternal repository, see
mule.apps
andmule.domains
properties inConfiguration section. - Improve CI/CD, buildingdocker images within seconds containingthe latest Mule Runtime version anddeploying your Mule Applications on a container management platform, for exampleKubernetes, to test integrations before deploying them to production.
- ...
The main dependency is JDK 8+. Tested with:
- JDK 8, JDK 9, JDK 10 and JDK 11 on Linux/Mac/Windows
- Spring Boot
2.1.0+
- Mule Runtime
4.2.1
-4.5.3
AddSpring Boot starter for Mule 4 dependency to your Spring Boot application's pom.xml file:
For Mule 4 CE Runtime (CommunityEdition, a.k.a.Kernel):
<dependency> <groupId>org.hawkore.springframework.boot</groupId> <artifactId>mule4-spring-boot-starter-ce</artifactId> <version>${mule4-spring-boot-starter.version}</version></dependency>
For Mule 4 EE Runtime (EnterpriseEdition):
<dependency> <groupId>org.hawkore.springframework.boot</groupId> <artifactId>mule4-spring-boot-starter-ee</artifactId> <version>${mule4-spring-boot-starter.version}</version></dependency>
This starter will add Mule Runtime dependencies to your Spring Boot application using Mule Runtime BOM (Bill Of Materials)specified by mandatory-D
command line argumentmule.bom.version
at build time,for example, to embed Mule Runtime 4.2.1 just runmvn clean package -Dmule.bom.version=4.2.1
.
Check availableMule Runtime CE BOM versions atMuleSoft's public maven repository.
Take a look atspring-boot-mule4-runtime-ce sample project (Mule Runtime CE 4.5.0).
Take a look atspring-boot-mule4-runtime-ee sample project (Mule Runtime EE 4.5.3).
Deployment services will allow you to manage Mule artifacts on a running spring-boot embedded Mule 4 Runtime:
- Deploy/un-deploy Mule Applications.
- Deploy/un-deploy Mule Domains.
- List deployed Mule Applications.
- List deployed Mule Domains.
To expose Mule 4 Runtime deployment services add@EnableSpringMuleRuntimeDeploymentServices
annotation:
@EnableSpringMuleRuntimeDeploymentServices@SpringBootApplicationpublicclassSpringBootEmbeddedMuleRuntime {publicstaticvoidmain(String[]args) {SpringApplicationapp =newSpringApplication(SpringBootEmbeddedMuleRuntime.class);app.setBannerMode(Mode.OFF);app.run(args); }}
Checkorg.hawkore.springframework.boot.mule.controller.MuleRuntimeDeploymentServices
implementation for more details.
Since there are several approaches on solving authentication and authorization in distributed web applications this starter doesn’t ship a default one.
A Spring Security configuration for deployment services could look like this:
@Configuration(proxyBeanMethods =false)publicclassSecuritySecureConfigextendsWebSecurityConfigurerAdapter {@Value("${server.port}")privateintserverPort;privateRequestMatcherforPortAndPath(finalintport,finalStringpathPattern) {returnnewAndRequestMatcher(forPort(port),newAntPathRequestMatcher(pathPattern)); }privateRequestMatcherforPortAndPath(finalintport,finalHttpMethodmethod,finalStringpathPattern) {returnnewAndRequestMatcher(forPort(port),newAntPathRequestMatcher(pathPattern,method.name())); }privateRequestMatcherforPort(finalintport) {return (HttpServletRequestrequest) ->port ==request.getLocalPort(); }@Overrideprotectedvoidconfigure(HttpSecurityhttp)throwsException {http.authorizeRequests( (authorizeRequests) ->authorizeRequests.requestMatchers(forPortAndPath(serverPort,"/mule/**")).authenticated().anyRequest().denyAll() ); }}
See alsoSecuring Client Actuator Endpoints.
Take a look atusage example to see how easy it is to run Mule 4 as a spring-boot application, and monitor it withSpring Boot Admin.
Take a look at theexample of distributed computation with Mule 4 and Kubernetes
The additional configuration of this starter can be provided by configuration properties - the Spring Boot way.All configuration properties start withmule
. Below is a list of the main supported properties:
Property | Values | Default value |
---|---|---|
mule.base | the mule's base folder (required) | |
mule.lazyInitializationEnabled | true ,false | false |
mule.xmlValidationsEnabled | true ,false | true |
mule.lazyConnectionsEnabled | true ,false | true |
mule.simpleLog | true ,false | true |
mule.cleanStartup | true ,false | false |
mule.domains | comma separated mule domain file(s) to be deployed at startup | |
mule.apps | comma separated mule application file(s) to be deployed at startup | |
mule.patches | list of patches' names for Mule Runtime with high load priority | |
mule.patchesPrefix | list of patch name prefixes for auto-load patches | MULE-,SE- |
mule.autoLoadPatches | true ,false | true |
mule.autoDeployArtifacts | true ,false | true |
mule.serverPlugins | comma separated mule server plugins file(s) to be installed at startup |
mule.cleanStartup
will clean deployed apps and domains folders before starting Mule Runtime, this is useful to deploy Mule Runtime with your "updatable" Mule application as a micro-service.mule.autoLoadPatches
will auto-load MULE PATCHES (dependencies starting with provided patches prefixes) into high priority classloader.mule.autoDeployArtifacts
will auto-deploy apps and domains found within classpath as resources.mule.domains
,mule.apps
andmule.serverPlugins
are loaded usingSpring's ResourceLoader, so you must provide a valid URL format:Prefix Example Explanation classpath: classpath:com/myapp.jar Loaded from the classpath. file: file:/opt/shared/myapp.jar Loaded as a URL, from the filesystem. http: http://myserver/myapp.jar Loaded as a URL.
Checkorg.hawkore.springframework.boot.mule.config.MuleConfigProperties
implementation for more details.
Build fails: mule-runtime-impl-bom not found when I try to package my Spring Boot application using starter-ce
For some Mule CE versions, MuleSoft does not release the Mule Runtime BOM to public maven repositories. To solve this:
Install Mule Runtime BOM into your local maven repository by yourself:
Clonemule-distributions github project.
git clone https://github.com/mulesoft/mule-distributions.git
Checkout a specific Mule's Version, replace
<tag_name>
with Mule's Version you need, for examplemule-4.2.2
:cd mule-distributionsgit checkout <tag_name>
Install
mule-distribution
parent pom:mvn clean install --non-recursive -Dmaven.test.skip=true -DskipTests=true -DskipVerifications=true -Prelease -DskipTests -DskipVerifications -DskipGpg -Dmaven.javadoc.skip=true
Install
mule-services-all
pom:mvn clean install -Dmaven.test.skip=true -DskipTests=true -DskipVerifications=true -f services-all/pom.xml -Prelease -DskipTests -DskipVerifications -DskipGpg -Dmaven.javadoc.skip=true
Install
mule-bom
pom:mvn clean install -Dmaven.test.skip=true -DskipTests=true -DskipVerifications=true -f bom/pom.xml -Prelease -DskipTests -DskipVerifications -DskipGpg -Dmaven.javadoc.skip=true
Copyright 2020HAWKORE, S.L.
Licensed under the Apache License, Version 2.0 (the "License");you may not use this file except in compliance with the License.You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, softwaredistributed under the License is distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions andlimitations under the License.
This project may contains subcomponents with separate copyrightnotices and license terms. Your use of the source code for thesesubcomponents is subject to their terms and conditions.
About
A 'Bootiful' approach to run Mule 4 embedded into a Spring Boot application.
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.