Blog Posts

How To Migrate from MuleSoft to Spring Boot with Smart Code

Migrating your microservices from MuleSoft to Spring Boot can feel like aa daunting task.  We break it down into clear simple steps to help you migrate with speed and ease.  Here is how.

Benefits of Spring Boot

Spring Boot has many benefits, the most notably being:

  1. Spring Boot applications simplify server installation by embedding it in the application.
  2. Spring Boot allows you to opt-in to auto-configuration.  This attempts to configure your spring application based on the dependencies you have added.  The user has control to exclude parts of the application from auto-configuration and provide their own.
  3. Spring Boot provides annotations to simplify configuration and reduce boiler plate code.
  4. Spring Boot streamlines dependency management with Spring Boot Starters.  There are over 30 starters available that go and grab all the dependencies you need to perform a specific type of function.
  5. Spring Boot is open-source, it’s reliable, and has a large community support network.

What you need to migrate

We are using the Smart Code REST Generator to migrate the MuleSoft API to Spring Boot.  To get started you are going to need 3 things.

  1. Target Schema

    This is the schema for the system that the API integrates with downstream. 

    • Check the MuleSoft API to see if the schema is saved under the resources folder.
    • Check the target system website to see if the schema is publicly downloadable.
    • Check to see if the RAML Specification matches the target payload.
    • Create a Postman Collection for the target system that best represents the payload.
  2. Source Schema

    This is the schema for the Spring Boot API, this will be the RAML Specification defined in the API folder of your MuleSoft API.  Because Spring Boot uses OAS as the standard, use the Smart Code UTIL Generator to convert it from RAML to OAS.  I suggest you convert it to OAS version 3.0, as there is limited support for 3.1.

  3. Mapping Instructions

    This is a simple JSON structure that shows you how to map the fields from source to target.  This is only required if the source and target field names are different.

    Do you want to map the target field on the object level or global level?
    • Object level mapping should reference the object name followed by the field name as defined in the schema, for example, “targetObject.targetField” : “sourceField”.
    • Global level mapping should prefix the field name with the ‘@’ symbol to tell the generator to map all instances of that field, for example, “@targetField” : “sourceField”.
    Do you want to map the field to a hard-coded value?
    • Hard-coded strings should be prefixed with the word ‘string’, for example, “targetField” : “string.my custom target value”.

Generating the API in Smart Code

  1. Parse the Target Schema

    To parse the schema using Smart Code REST Generator, navigate to the Generator tab and select the type of schema you want to use in the drop down.

    Then select the target schema and select parse.

    The status bar will tell you when it has parsed, loaded the documentation for Swagger UI, and loaded the endpoints in the generator.

  2. Select the Endpoints

    To effectively microservice off the target application select the endpoints you want generated in your Spring Boot API.  Check the MuleSoft API to see what was implemented, and choose the same.

  3. Map the Source

    If the source schema is the same as the target, you can choose to generate it.  For Spring Boot the standard is OAS format.

    If the source schema is different to the target, you will select ‘Custom’.  With this setting the mapping instructions are mandatory.

  4. Generate the API

    Set the language to Spring Boot – Java, give the API a name and set the Group ID required for Maven.  Once this is all filled out, select the generate button. 

    The status bar will complete and you will be navigated to the downloads page.

API Development

Once you have downloaded the API from Smart Code, extract and import it into the developer IDE.

What Smart Code gives you:
  • Error Handling
  • Logging
  • Controllers
  • Service and Service Implementations
  • SOAP Headers (if required)
  • Field Mapping in Mapstruct (if required)
What the developer will need to complete:

  • Business Logic as defined in the MuleSoft API
  • Customizations

Final Thoughts

We use Smart Code to cut down the amount of manual development required for the migration. Other benefits include consistent error handling and logging standards, performance optimizations through Spring Webflux and developer support.

Leave a Reply

Your email address will not be published. Required fields are marked *