VM Component in Mule 4

VM component in Mule 4

·                     The Virtual Machine (VM) connector handles intra-app and inter-app communication through asynchronous queues that can be transient or persistent.
·                     Transient queues are faster than persistent queues, but they are not reliable in the case of a system crash.
·                     Persistent queues are slower but reliable.
·                     When running on a single instance, persistent queues work by serializing and storing the contents on the disk.

When to Use the VM Connector: 
·                     When you want to pass messages from one flow to another through a queuing mechanism, instead of using <flow-ref /> directly.
·                     When you want to distribute work across a cluster.
·                     When you want to communicate with different apps that are running in the same Mule domain.
·                     When you need simple queuing that does not justify a full JMS broker.

Components in VM

1. Publish: Publish the content to the queue
2. Listen: It listen to the VM queues
3. Consume: Pull one message from a queue. If message is not immediately available, message will wait up to configured queue timeout.
4. Publish Consume: Publishes the given content into a queue and then awaits up to the queuetimeout for a response to be supply on a temporal reply- to queue that this operation automatically creates.

Flow of Publish:

Publish component configuration:

Connector configuration:

Flow of listener:

Method: GET



So, you can see clearly that process is asynchronous and separate threads are executing for both the flows.
First thread is executing loggers before vm and after vm and second thread is executing payload logger that is Hello.

Flow of publish consume:

Flow of listener:

Method: GET

Here you can see same thread is executing all the loggers one after one.

XML project code:

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

<mule xmlns:sockets="http://www.mulesoft.org/schema/mule/sockets" xmlns:http="http://www.mulesoft.org/schema/mule/http"
     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/vm http://www.mulesoft.org/schema/mule/vm/current/mule-vm.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/sockets http://www.mulesoft.org/schema/mule/sockets/current/mule-sockets.xsd">
     <vm:config name="VM_Config" doc:name="VM Config" doc:id="162fd81e-d7e3-4443-b95c-068f452be47b">
          <vm:queues >
              <vm:queue queueName="vm" />
     <http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config" doc:id="f34f130a-ff45-41df-a8b0-e5a1192329a4" >
          <http:listener-connection host="" port="8085" />
     <flow name="test_vmFlow" doc:id="7cd43a2d-0bec-400a-93e7-92f1fd6bf145" >
          <http:listener doc:name="Listener" doc:id="f941a0ea-db90-471d-97b4-b94002d4c608" config-ref="HTTP_Listener_config" path="/vm"/>
          <logger level="INFO" doc:name="Logger" doc:id="9675b9e8-d6b2-4720-9f68-3ab0094ea9e9" message="before vm"/>
          <vm:publish queueName="vm" doc:name="Publish" doc:id="9df15d7a-792a-40a8-ad13-96ed7108475e" config-ref="VM_Config" sendCorrelationId="ALWAYS">
          <logger level="INFO" doc:name="Logger" doc:id="cbcf0b10-3a48-43d5-ba7b-c5dec877a457" message="after vm"/>
     <flow name="test_vmFlow1" doc:id="69cd8eb2-0fd5-408c-bc25-251c40249198" >
          <vm:listener queueName="vm" doc:name="Listener" doc:id="30fd3738-201b-4428-8e90-42140ec82688" config-ref="VM_Config"/>
          <logger level="INFO" doc:name="Logger" doc:id="106b97e9-9be5-462c-8303-dffc60777e85" message="#[payload]"/>
     <flow name="test_vmFlow2" doc:id="46726825-5875-41b8-b498-47a3622c00fa" >
          <http:listener doc:name="Listener" doc:id="34fdd984-c2db-4235-852a-e052a542ec8b" config-ref="HTTP_Listener_config" path="/vm1"/>
          <logger level="INFO" doc:name="Logger" doc:id="3c4cd112-9d94-4e1f-9316-2f9aca97df8d" message="before vm"/>
          <vm:publish-consume queueName="vm" doc:name="Publish consume" doc:id="23ca2046-49d1-4786-b6b4-e412296d031b" config-ref="VM_Config"/>
          <logger level="INFO" doc:name="Logger" doc:id="76f7a5a4-b3e2-4639-a6f1-882c3c08a418" message="after vm"/>
     <flow name="test_vmFlow3" doc:id="46cf614a-3464-49ee-b378-323d93dbe09f" >
          <vm:listener doc:name="Listener" doc:id="26f18453-7287-46ea-bd4e-a47bce7af9b5" config-ref="VM_Config" queueName="vm"/>
          <logger level="INFO" doc:name="Logger" doc:id="149cf101-6bb7-4f1d-840e-150ba1e6a780" message="#[payload]"/>
<!--      <flow name="test_vmFlow1" doc:id="d2781c31-b6e2-4394-883c-f7afc844ecd1" >
          <vm:listener queueName="vm" doc:name="Listener" doc:id="62ab05f9-3adc-4ff4-a646-58603c2b719f" config-ref="VM_Config"/>
          <logger level="INFO" doc:name="Logger" doc:id="9c30c72f-51a6-49f4-8d63-9d1be38cc32b" message="after vm #[payload]"/>
     </flow> -->

No comments:

Post a Comment

If you have any doubt, please let me know

© 2020 goformule.com

Share on :

Mule 4:

XML to JSON in mule 4 Web service consumer VM Validation in Mule 4 Until Successful
Sub flow Set Variable & Remove Variable Set Transaction ID Scatter Gather Round Robin
Consume Restful Service CRUD in Mule 4 Parse Template Object to JSON Load Static Resource
JSON to XML Invoke Idempotent Filter ForEach Flat file to JSON
Fixwidth to JSON First Successful File Execute Error Handling
Email Dynamic Evaluate Custom Business Event CSV to JSON Copybook to JSON
Choice Router Async RabbitMQ

Mule 3:

Database Connector Async CXF Attachement XSLT
Mongo DB Cache scope Custom Business Event Gzip Compress Expression
SMTP For Each Expression Javascript Filter Reference
Salesforce Message Enricher Groovy Parse Template Idempotent
VM Poll Invoke Ruby Message
Webservice consumer Python Transformer reference Message Property Not
Collection Aggregator First Sucessful Catch Exception Strategy Reference Exception Strategy Or
Choice Message Chunk Aggregator Choice Exception Strategy Global Exception Strategy Schema Validation
Custom Aggregator Scatter Gather Custom Exception Strategy Batch Processing MEL
M Unit RAML Map Operator API Mocking Dataweave

Converter Tools :

JSON to XML Converter XML to JSON Converter Decimal to Binary Decimal to Octal Binary to Decimal
Binary to Hexadecimal Binary to Octal Hexadecimal to Decimal Hexadecimal to Binary Hexadecimal to Octal
Octal to Decimal Octal to Binary Octal to Hexadecimal Number to Words Converter Text to Hex Converter
Hex to Text String to Binary Converter Binary to String Converter Word to HTML Converter Word to PDF Converter
JSON to YAML Converter CSV to JSON Converter XML to XSLT Converter XML to YAML Converter
JSON to CSV Converter JSON to TSV Converter CSV to TSV Converter CSV to XLS Converter

Image Tools :

PNG to JPG Converter PNG to BMP Converter PNG to GIF Converter JPG to PNG Converter JPG to BMP Converter
JPG to GIF Converter GIF to PNG Converter GIF to JPG Converter GIF to BMP Converter PNG to PDF Converter
JPEG to PDF Converter JPG to PDF Converter BMP to PDF Converter GIF to PDF Converter

String Utilities :

Reverse String Random String Generator Base64 Encoder Base64 Decoder Words Counter
Remove Accents Remove Duplicate Lines Remove Empty Lines Remove Line Breaks Remove Similar Lines
Sort Text Lines Reverse Text Lines Random Words Generator

Number Utilities :

Square Root Calculator Random Number Generator Area of Circle Calculator Date Calculator

Other Tools :

Find IP of Website Password Generator URL Encoder URL Decoder lorem ipsum Generator
IP to Hostname Port Checker JSON Escape JSON Unescape

Free Rest APIs for Testing :

GET Sample Rest APIs POST Sample Rest API PUT Sample Rest API PATCH Sample Rest API DELETE Sample Rest API
Login Sample Rest API User Registration Sample API User Registration Unsuccessful Sample Rest API Delay Response