Blog Banner Image

Mule 3 vs Mule 4: 6 Reasons why you should upgrade?

When it’s about connecting devices, data, and applications over Software-as-a-Service (SaaS), on-premises, APIs, and enterprise’s legacy systems, MuleSoft is a name, companies’ loves to count upon. With its newly released Mule 4, which incorporates advanced features such as self-tuning engines, this integration software provider has once again created a lot of buzz across industries.

Mule 4 is the new runtime offered by MuleSoft. It is uniquely designed to boost the developer’s confidence as it reduces the steps to develop applications by approximately 50%. It delivers enhanced connectivity and supports super-fast data access, which aids to the learning experiences of developers. Let’s briefly understand why Mule 4 is worth upgrading to and demystify various other capabilities of MuleSoft’s newly released runtime.

Mule 3 vs Mule 4: Differences 

Mule 3 gained the market traction for long and when the version was upgraded to Mule 4, it was based on the former’s reputation. And hence, special attention has been given while developing Mule 4. It has been designed to boost scalability and support performance optimization and smooth upgrade, but let’s understand how. 

1. Self-Tuning Engine

With Mule 4, there is no need to manually tune the runtime. It incorporates the self-tuning engine which allows developers to reap the benefits of non-blocking I/O (Input/Output) calls. Self-tuning engine automates the strategy-processing configuration, dynamically adjusts the runtime, and makes it apt for disparate workloads. Thus, it essentially helps evade performance bottlenecks. 

With Mule 4 self-tuning engine, the developers need not manually perform diverse steps such as threading configuration and data-pattern exchange declaration. Developers can put the entire application flow development in a single thread. 

2. Thread Pools 

In Mule 4, thread pooling is not done manually. The programs use the Mule runtime’s default values, which is self-tuned. However, if there is a need to do it manually, the users should configure the minimum and maximum thread values with the wait time in the conf/scheduler-pools.conf file.

org.mule.runtime.scheduler.io.threadPool.threadKeepAlive=30000
org.mule.runtime.scheduler.cpuLight.threadPool.size=2*cores
org.mule.runtime.scheduler.cpuIntensive.workQueue.size=30000

Each different connector in the Mule runtime hints the users, if it is IO Intensive, CPU Light, or CPU Intensive, allowing the runtime to self-tune. In case the Mule connectors do not provide users with any hints, the Mule 4 runtime will automatically analyze the connector codes and assign thread pools.

3. Error Handling

  Mule 3 did not help in identifying the nature of errors. Earlier the handling of errors was based on Java exception, which followed a trial and error approach. Therefore, Mule 3 made the developers work lengthy and tiresome.

On the contrary, Mule 4 supports error detection and handling during the design development time. The errors are neatly typed and come with detailed problem statements. Thus, it becomes convenient for developers to instantly identify and resolve errors. 

4. DataWeave 2.0 

The earlier versions of Mule runtime consisted of DataWeave and Mule Expression Language (MEL), which delivered a constant experience while handling expressions such as JSON. However, it lacked the ability to manage transformations of data and mule messages and also created a fragmented environment.

In Mule4, MEL is not used as the messages directly pass through a connector. Mule 4 incorporates DataWeave 2.0, which is an extended version of its default expression language—DataWeave. It organizes and simplifies the data and makes it easy to learn. Moreover, it boosts the integration abilities by helping create reusable codes to allow users instantly access data without the need to transform them. The data and messages stored in JSON and CSV, or any other forms, can be directly accessed by creating expressions.
  
5. Smooth User-Experiences 
Following charts will help you better understand the difference in the application flow development of Mule 4 and Mule 3.
  
Mule 4 Flow: 

.

XML

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" xmlns:file="http://www.mulesoft.org/schema/mule/file"
    xmlns:batch="http://www.mulesoft.org/schema/mule/batch"
    xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/batch http://www.mulesoft.org/schema/mule/batch/current/mule-batch.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd">
    <flow name="MainProcessFlow" doc:id="c97e2dd9-62ca-4e9a-9635-0ae49cbf81c1" maxConcurrency="100">
        <file:listener doc:name="On New or Updated File" doc:id="92383749-1e3c-4990-bde1-36fc79449d04" directory="Desktop/files/input" moveToDirectory="Desktop/files/output">
            <scheduling-strategy>
                <fixed-frequency />
            </scheduling-strategy>
            <file:matcher filenamePattern="data.csv" />
        </file:listener>
            <ee:transform doc:name="Transform Message" doc:id="5a90ba3a-3919-4747-8e24-d24ee547c7c1">
            <ee:message>
                <ee:set-payload><![CDATA[%dw 2.0
output application/java
---
payload]]></ee:set-payload>
            </ee:message>
        </ee:transform>
        
        <flow-ref doc:name="Flow Reference" doc:id="5f006dd3-9fa5-49d4-86d3-7568e6cce714" name="BatchProcessFlow" />
    </flow>
    <flow name="BatchProcessFlow" doc:id="6d282a48-c024-4aea-b9ff-bcc9a5df018f" maxConcurrency="100">
        <batch:job jobName="BatchProcessBatch_Job" doc:id="b5d08ba2-651b-45f4-8fdc-7c36c18c3ee9" blockSize="1000" maxConcurrency="100">
            <batch:process-records >
                <batch:step name="Batch_Step" doc:id="a30ffad3-37d0-4af0-920e-95f43271b345" >
                    <logger level="INFO" doc:name="Print Logger" doc:id="85963f29-dd61-435d-aa8e-3b37fd3f1de8" message="------------#[payload]"/>
                </batch:step>
            </batch:process-records>
        </batch:job>
    </flow>
</mule>

Mule 3 Flow

.

XML:    

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking"
    xmlns:email="http://www.mulesoft.org/schema/mule/email" xmlns:metadata="http://www.mulesoft.org/schema/mule/metadata"
    xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns:dw="http://www.mulesoft.org/schema/mule/ee/dw"
    xmlns:batch="http://www.mulesoft.org/schema/mule/batch" xmlns="http://www.mulesoft.org/schema/mule/core"
    xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
    xmlns:spring="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
http://www.mulesoft.org/schema/mule/batch http://www.mulesoft.org/schema/mule/batch/current/mule-batch.xsd
http://www.mulesoft.org/schema/mule/ee/dw http://www.mulesoft.org/schema/mule/ee/dw/current/dw.xsd
http://www.mulesoft.org/schema/mule/email http://www.mulesoft.org/schema/mule/email/current/mule-email.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd">
    <non-blocking-processing-strategy
        name="Non_Blocking_Processing_Strategy" maxThreads="500" minThreads="50"
        threadTTL="1000" doc:name="Non Blocking Processing Strategy" />
    <asynchronous-processing-strategy
        name="Asynchronous_Processing_Strategy" maxThreads="500" minThreads="50"
        threadTTL="1000" doc:name="Asynchronous Processing Strategy" />
    <flow name="MainProcessFlow">
        <file:inbound-endpoint path="C:/Users/sadik.ali/Desktop/files/input"
            moveToDirectory="C:/Users/sadik.ali/Desktop/files/output"
            responseTimeout="10000" doc:name="File">
            <file:filename-regex-filter pattern="dat.csv"
                caseSensitive="true" />
        </file:inbound-endpoint>
        <file:file-to-string-transformer
            returnClass="java.lang.String" mimeType="application/java" doc:name="File to String" />
        <dw:transform-message doc:name="Transform Message">
            <dw:input-payload mimeType="application/csv">
                <dw:reader-property name="ignoreEmptyLine" value="true" />
                <dw:reader-property name="separator" value="|" />
            </dw:input-payload>
            <dw:set-payload><![CDATA[%dw 1.0
%output application/java
---
payload]]></dw:set-payload>
        </dw:transform-message>
        <batch:execute name="BatchProcessFlow" doc:name="Batch Execute" />
    </flow>
    <batch:job name="BatchProcessFlow" block-size="500">
        <batch:process-records>
            <batch:step name="Batch_Step">
                <logger message="-------------------------------------#[payload]"
                    level="INFO" doc:name="Logger" />
            </batch:step>
        </batch:process-records>
    </batch:job>
</mule>

Having compared the application flow development in both Mule3 and Mule4, we will observe that there is no major difference. Mule4 is only about delivering smooth user-experience. With no multiple threads, easy to learn language, instant access to data, and enhanced connectivity, Mule4 is about boosting the capabilities of developers. 

6 Application Log 

Following are the Mule 3 vs. Mule 4 application logs. When you compare the applications logs for both versions of the runtime, the differences can easily be identified.  

Mule 4 

In the Mule 4 application log below, you will see that the thread profile is being assigned by the runtime during the data processing—[[MuleRuntime].io and [[MuleRuntime].cpuIntensive. These thread pools are assigned to flow process-based thread requirements. 


       IO thread pool:
 

        IO thread pool

 

Intensive thread pool:

IO thread pool 1

​​​​​​

Mule 3 

In the Mule 3 application log given below, you will not find any such self-tuning capabilities for data processing. In order to scale-up the performance in Mule 3, profiling of the process is required, which is self-assigned in Mule 4.

IO thread pool 2

 

Mule 4 – Boosting Innovation, Scalability, and Performance  

Mule 4 augments the speed of developers and cut short the integration time. Facilitating single-thread pool of the entire application development flow, self-tuning of the runtime engine, enhanced message models, and effective streaming, Mule 4 boosts developer’s confidence and helps enterprises optimize performance.

This updated version of Mule runtime engine boosts its Anypoint Platform, which facilitates seamless connectivity. With Mule 4 self-tuning capabilities, the Anypoint Platform allows developers to build robust applications with comparatively faster speed and also enables them to successfully steer to new levels of innovation.