DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Use of Transient Variable in JavaScript With Camunda External Task
  • How to Use Mulesoft VM Connector

Trending

  • Stateless JWT Auth Microservice Architecture With Spring Boot 3 and Redis Sentinel
  • Contract-First Integration: Building Scalable Systems With Flyway, OpenAPI, and Kafka
  • The Hidden Cost of AI Tokens: Engineering Patterns for 10x Resource Efficiency
  • Building a High-Throughput Distributed Sequence Generator Using the Hi-Lo Algorithm

Persistent and Transient Queues in Mule

To prove the persistence of Mule’s queues on-premise, I created a project with two different configurations for VM already set and each of with a different queue name.

By 
Maria Avila user avatar
Maria Avila
·
Feb. 14, 21 · Analysis
Likes (6)
Comment
Save
Tweet
Share
16.6K Views

Join the DZone community and get the full member experience.

Join For Free

Hi, I'm a nearshore MuleSoft Developer and this article is an analysis of the persistent and transient queues in Mulesoft.

At the moment of publishing the article, I’m using:

  • Anypoint Studio: 7.3.3

  • Mule Runtime: 4.1.5

There are two types of queues in Mule: TRANSIENT and PERSISTENT.

On-premise Behavior

Realized tests using both types of queues.

  • Transient queue proved to be faster than persistent because data is stored in memory. Because of this, if the application or server is turned off or is down due to a failure, a message placed in the queue will be lost.

  • Meanwhile, the persistent queue had to write to the disk to persist the data in it, becoming slower. However, there is an advantage to it, since the message is serialized onto the disk even if the server has a downtime the data will be recoverable once the Mule server is up and running again. The recovered message in the VM queue will be picked up automatically as inbound data in the listener.

For each persistent queue defined, Mule created 3 files:

  • <queueName>-1
  • <queueName>-2
  • <queueName>-crl

Fig.1 One persistent queue, named 'PersistentQ', with its generated three files.

Fig.1 One persistent queue, named 'PersistentQ', with its generated three files.


“When running on a single instance, persistent queues work by serializing and storing the contents onto the disk.”

Fig.2 The serialized message in the file.

Fig.2 The serialized message in the file.

Working in Clusters

If an app using VMs is deployed in a cluster, Mule runtime will decide in which node of the cluster the info will be saved. 

Scenario

To prove the persistence of Mule’s queues on-premise, I created a project with the two different configurations for VM already set and each of them with a different queue name, this way I only had to pass over a query parameter to decide in which queue to write, based on the value sent. I used an HTTP listener to post messages in any of the queues.

Fig.3 The publish flow triggered by a POST request.

Fig.3 The publish flow triggered by a POST request.


Fig.4 Flow for setting the name which is linked to the set configuration for the VM type.

Fig.4 Flow for setting the name which is linked to the set configuration for the VM type.

For reading messages, I used a GET request to trigger a consume operation, this way I could control when to read messages from the VM queue. So, I could place messages into both queues, then stopping the application and when starting again, validate which messages were lost or remained.

Fig.5 The consume flow trigger by a get request.

Fig.5 The consume flow trigger by a get request.

In this example, I’m testing two messages in the persistent queue and two more in the transient.

Fig.6 Console receiving 4 messages.

Fig.6 Console receiving 4 messages.


Fig.7 and 8 Stopping and Running the application again.

Fig.7 and 8 Stopping and Running the application again.


 Fig.9 Consuming two messages from the persistent queue, none from the transient after the restart.

 Fig.9 Consuming two messages from the persistent queue, none from the transient after the restart.

CloudHub Behavior With Only One Instance (1 Worker) 

  • Mule Runtime: 4.1.5

  • Environment: Sandbox

  • One Worker

In order to use persistent queues in CloudHub, when your application has been deployed, it is necessary to tick the 'Persistent Queue' checkbox in the application settings in Runtime Manager. 

Note: With a trial account this is not possible because the check box of Persistent Queues is disabled, it is necessary for an Enterprise Account to select persistent queues. 

This 'Persistent Queue' option overrides any configuration done in the Mule configuration files. If enabled, all queues become persistent. If not selected, all queues are set as transient, even if they were configured as persistent in Mule configuration files. 

Conclusions

 

 

 

Local 

Transient Queue

Persistent Queue

It is faster.

It is slower.

Not trustworthy in case of a system crash.

Reliable.

Messages not saved.

Saved in files.

CloudHub 

Not trustworthy in case of a system crash.

Reliable.

Not saved.

Saved in AWS queues 

Bonus Topic 

Why call a VM connector if we have a flow reference? 

If you want a task to be processed asynchronously (decoupled) you should use a VM connector, the task will continue in the flow that received the message — this can help you free resources. However, you can use a VM in a synchronous way too and persist the messages, but resources will not be freed. 

Transient (computer programming)

Opinions expressed by DZone contributors are their own.

Related

  • Use of Transient Variable in JavaScript With Camunda External Task
  • How to Use Mulesoft VM Connector

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook