Measures of Dispersion and Variability: Range, QD, AD and SD
Hyd MuleSoft-Meetup-May 29,2021 | Migrating Mule 3 Java related code to Mule 4
1. 29th March 2021 , 4pm IST
Hyderabad MuleSoft Meetup
MIGRATING MULE 3 JAVA RELATED CODE TO MULE 4
2. Agenda
•Community Details!
•Introduction Of Organizers and Speakers
•Important Announcements – Anypoint Studio New Release
•Migrating Mule 3 Java Related Code to Mule 4 by Piyush Sharma
•Queries
•Trivia Quiz
2
3. Community Details
• Register for Meetups : https://meetups.mulesoft.com
•Register for Official Training platform : https://training.mulesoft.com
•MuleSoft forum : https://help.mulesoft.com
•For all blogs : https://blogs.mulesoft.com/
•Anypoint platform : https://anypoint.mulesoft.com
•Join Exam Readiness Sessions ! (Remind me to share at the end of the session)
3
5. Speaker of the day!
5
• Working as an Integration developer with 5+ years’
of experience in different domains like retail,
banking, consumer goods, healthcare etc and
helping organizations in their digital transformation
journey.
• Started career with TIBCO and slowly moved to
MuleSoft.
• Happy to help and contribute to MuleSoft
community and eventually learning new things in
process. Love to travel and watch movies in free
time.
Reachable:
https://www.linkedin.com/in/piyush3192/
7. 2
New Anypoint Studio 7.9.0
• Anypoint Studio 7.9 enables users to use a dark theme, and upgrades its
underlying infrastructure to Eclipse 4.18 and Java 11, adding official
support for macOS Big Sur.
• This version also introduces improvements for Dataweave code
experience and enhanced macOS experience by notarizing Studio as a
macOS application.
14. 14
Mule 4 Java Working
Several ways of calling Java:
• Calling Static Java Methods from DataWeave
• Scripting Module (Ruby, Python,Groovy,JS)
• Java Module
15. 15
A look on Mule 3 Java Code
15
Mule API Packages
Callable Interface
Getting payload and flow
variables
Setting flow variables and
return payload
16. 16
16
Basic knowledge of Mule 3 Java class
Mule API Package Imports:
import org.mule.api.lifecycle.Callable;
import org.mule.api.MuleEventContext;
import org.mule.api.transport.PropertyScope;
Class with callable interface:
public class AddtwoNum implements Callable
Oncall method
@Override
public Object onCall(MuleEventContext eventContext) throws Exception
17. 17
17
Basic knowledge of Mule 3 Java class
Read flow Variables according to their scope:
myVar = eventContext.getMessage().getProperty(“name", PropertyScope.INVOCATION);
Set flow Variables according to their scope:
eventContext.getMessage().setProperty(“name", “Max”, PropertyScope.INVOCATION);
Read payload:
String payload = (String) eventContext.getMessage().getPayload();
Return payload:
return eventContext.getMessage().getPayload();
18. 18
18
Migrating Java functionality Mule 3 to Mule 4
Combined Approach:
• Java classes cannot be simply migrated, requires manual efforts.
• Utilize MMA tool along with custom changes.
• Migrate most of the code and connector configuration using MMA.
Identify and Address:
• Identify Java classes which you really need to migrate.
• Utilize Dataweave 2.0 at most of the places and scrap the old used java class for data
transformation for improved performance and readability.
• List down the java classes which have to be migrated.
19. 19
19
Migrating Java functionality Mule 3 to Mule 4
Work with classes:
• Once class finalized, start importing them. Please watch out for classes which import other classes
as well.
• Fix project structure and error, you might require to add dependency which are used in java class.
• Sometimes you need to allow certain packages in studio which gets restricted.
• After importing classes, there will be errors in classes as well, that’s where the manual efforts needs
to be done.
20. 20
20
Migrating Java functionality Mule 3 to Mule 4
Modify classes:
• Remove all imports related to org.mule.api.*, as they are no longer supported in Mule 4.
• Remove callable interface notation from class declaration(public class AddTwoNum implements Callable ->
public class AddTwoNum )
• Modify onCall method , rename it and make it static.
• Check for flow variables or properties which code reads, you now need to pass them as a parameters in
static method.
• Check for return type of method, if it doesn’t return anything it will be void, otherwise based on return
datatype.
25. Enter Your Full Valid Name (no nick Names are allowed)
Only those who have registered and joined the session will be
allowed!
Goto Mobile Browser
Enter :
kahoot.it