Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A 'Bootiful' approach to run Mule 4 embedded into a Spring Boot application.

License

NotificationsYou must be signed in to change notification settings

hawkore/mule4-spring-boot-starter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

81 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spring Boot Starter for Mule 4

LicensecodecovSonar Quality GateReleasejavadocMaven central

A 'Bootiful' approach to run Mule 4 embedded into a Spring Boot application.

Table of Contents

Getting Started

Overview

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, seemule.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.
  • ...

Prerequisites

The main dependency is JDK 8+. Tested with:

  • JDK 8, JDK 9, JDK 10 and JDK 11 on Linux/Mac/Windows
  • Spring Boot2.1.0+
  • Mule Runtime4.2.1-4.5.3

Dependencies

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>

Mule Runtime versions

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).

Expose deployment services

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.

Securing Deployment Services

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.

Simple usage example

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.

Kubernetes deployment example

Take a look at theexample of distributed computation with Mule 4 and Kubernetes

Appendix

Configuration

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:

PropertyValuesDefault value
mule.basethe mule's base folder (required)
mule.lazyInitializationEnabledtrue,falsefalse
mule.xmlValidationsEnabledtrue,falsetrue
mule.lazyConnectionsEnabledtrue,falsetrue
mule.simpleLogtrue,falsetrue
mule.cleanStartuptrue,falsefalse
mule.domainscomma separated mule domain file(s) to be deployed at startup
mule.appscomma separated mule application file(s) to be deployed at startup
mule.patcheslist of patches' names for Mule Runtime with high load priority
mule.patchesPrefixlist of patch name prefixes for auto-load patchesMULE-,SE-
mule.autoLoadPatchestrue,falsetrue
mule.autoDeployArtifactstrue,falsetrue
mule.serverPluginscomma 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:

    PrefixExampleExplanation
    classpath:classpath:com/myapp.jarLoaded from the classpath.
    file:file:/opt/shared/myapp.jarLoaded as a URL, from the filesystem.
    http:http://myserver/myapp.jarLoaded as a URL.

Checkorg.hawkore.springframework.boot.mule.config.MuleConfigProperties implementation for more details.

Help and troubleshooting

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:

    1. Clonemule-distributions github project.

      git clone https://github.com/mulesoft/mule-distributions.git
    2. 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>
    3. Installmule-distribution parent pom:

      mvn clean install --non-recursive -Dmaven.test.skip=true -DskipTests=true -DskipVerifications=true -Prelease -DskipTests -DskipVerifications -DskipGpg -Dmaven.javadoc.skip=true
    4. Installmule-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
    5. Installmule-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

License

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.

About subcomponents

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

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp