Mule 3 to Mule 4 migration using Mule Migration Assistant

 

In this tutorial we will talk about how to migrate the MuleSoft code from Mule 3 to mule 4 using the newly released open source project mule migration assistant (MMA).

Mule Migration Assistant

Since the launch of Mule 4 (with many benefits) and the end of support for 3.x, there has been an urgent need in every organization to migrate the code from Mule 3.x to Mule 4.x.

You can follow two approach to migrate the old 3.x code to new 4.x code. One is to rewrite the complete code in mule 4, which is not an easy task. Another approach is to use MMA tool to migrate the application from mule 3.x to mule 4.x.

Although MMA does not do the job perfectly, but it eases the migration for you. It also provides you a report of issues, generated during migration, which you would need to correct for the complete migration to 4.x.  If you want to read more on mule Migration Assistant, you can refer to link MMA

 

Prerequisite

Here are the prerequisite for the Migration.The minimum requirement is version 7.3.0 for Anypoint studio and 4.3 for Mule Runtime.

 

Steps for Migration

 

Here are the steps to migrate the code from Mule 3.x to Mule 4.x.

 

Open any Mule 3.x project in the Anypoint studio 6.x

mule migration assistant

 

Create Mule 4.x project from mule 3.x project USING MMA Tool

 

Download the MMA zip file and unzip it. Run the command below from the unzipped directory as below.

java -jar mule-migration-assistant-runner-1.0.0.jar -muleVersion 4.3.0 -projectBasePath C:\Users\mulesy\AnypointStudio\workspace6\test-project -destinationProjectBasePath C:\Users\mulesy\AnypointStudio\workspace6\test-project-mule4

 

 

After successful execution of the command you would see the result and the new project as below

 

D:\Application\mule-migration-assistant-runner-1.0.0>java -jar mule-migration-assistant-runner-1.0.0.jar -muleVersion 4.3.0 -projectBasePath C:\Users\mulesy\AnypointStudio\workspace6\test-project -destinationProjectBasePath C:\Users\mulesy\AnypointStudio\workspace6\test-project-mule4
Executing migrator 1.0.0...
===============================================================================
MIGRATION ASSISTANT RUN SUCCESSFULLY
===============================================================================
Total time: 4.861 s
Migration report: C:\Users\mulesy\AnypointStudio\workspace6\test-project-mule4\report\summary.html
D:\Application\mule-migration-assistant-runner-1.0.0>

 

 

mule migration assistant

 

Open the project in studio 7.3 or higher version

 

mule migration assistant

 

Open the Summary Report for issues

 

Open the Summary report generated by MMA tool for the issues during the conversion. The report would be created inside the {project}\report\summary.html .The issues are categorized as Errors, Warnings, and Info for classification of the issues. We need to fix these issues before we run the project in 4.3 version.

test-project-mule4\report\summary.html

mule migration assistant

 

Click on each issue link to get detail of the issue as below

 

Steps to resolve the above issues.

 

  • Configure the oracle JDBC driver to fix the first issue. Add the ojdbc dependency to fix this.
  • Delete the http status code xml snippet as below.
<http:response statusCode=<em>"#[migration::HttpListener::httpListenerResponseSuccessStatusCode(vars)]"</em>>
<!--Migration WARN: Avoid using an outbound property to determine the status code.-->
<!-- For more information refer to:-->
<!-- * https://github.com/mulesoft/mule-migration-assistant/blob/master/docs/user-docs/migration-tool-post-mig.adoc#outbound_properties-->
<http:headers>#[migration::HttpListener::httpListenerResponseHeaders(vars)]</http:headers>
</http:response>
<http:error-response statusCode=<em>"#[vars.statusCode default migration::HttpListener::httpListenerResponseErrorStatusCode(vars)]"</em>>
<!--Migration WARN: Avoid using an outbound property to determine the status code.-->
<!-- For more information refer to:-->
<!-- * https://github.com/mulesoft/mule-migration-assistant/blob/master/docs/user-docs/migration-tool-post-mig.adoc#outbound_properties-->
<http:headers>#[migration::HttpListener::httpListenerResponseHeaders(vars)]</http:headers>
</http:error-response>
  • Delete the “Attributes to inbound properties” as we do not need it
<compatibility:attributes-to-inbound-properties>
<!--Migration WARN: Expressions that query 'inboundProperties' from the message should instead query the message 'attributes'. Remove this component if there are no uses of 'inboundProperties' in expressions or components that rely on 'inboundProperties' (such as 'copy-properties').-->
<!-- For more information refer to:-->
<!-- * https://docs.mulesoft.com/mule-runtime/4.3/intro-mule-message#inbound-properties-are-now-attributes-->
<!-- * https://github.com/mulesoft/mule-migration-assistant/blob/master/docs/user-docs/migration-tool-post-mig.adoc#inbound_properties-->
</compatibility:attributes-to-inbound-properties>

 

  • Delete the “Outbound properties to var” as we do not need it
<compatibility:outbound-properties-to-var>
<!--Migration WARN: Instead of using outbound properties in the flow, move the expression that sets the property into the XML attribute (such as 'method') of the operation or listener that accepts the expression.-->
<!-- For more information refer to:-->
<!-- * https://github.com/mulesoft/mule-migration-assistant/blob/master/docs/user-docs/migration-tool-post-mig.adoc#outbound_properties-->
</compatibility:outbound-properties-to-var>

 

  • Update the “flowVars” to vars

 

Run the new mule 4.x application.

 

Once all the issues are resolved. Run the project and it should start seamlessly.

 

Resources

Here is the project we used for the conversion. We have added both 3.x and converted 4.x project for your reference.

Mule 3.x sample project

Mule 4.x migrated project

  
Thank you for taking out time to read the above post. Hope you found it useful. In case of any questions, feel free to comment below. Also, if you are keen on knowing about a specific topic, happy to explore your recommendations as well.
 
For any latest updates or posts on our website, you can follow us on LinkedIn. Look forward to connecting with you there.


Share this:
Subscribe
Notify of
guest
4 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Sudhir
Sudhir
4 years ago

Good site for mulesoft…I need mulesoft support and admin side concepts. Can you please help me on this.

Radhesham Pandit
Radhesham Pandit
3 years ago

Good site for mulesoft developers. It’s made simple to learn from here and all concepts explain in easy and quite simple language. Love it.

Noah
Noah
2 years ago

Hello, would you mind uploading Mule Migration Assistant v1.3. The one that’s attached to this article is 1.0.0.
Thanks in advance

Thanga
Thanga
2 years ago

Need to migrate mule 3 project which is having domain project as well using MMA tool.. help me on this.