7
Basic Example Using VM Component

Basic example using vm component

Embed Size (px)

Citation preview

Page 1: Basic example using vm component

Basic Example Using VM Component

Page 2: Basic example using vm component

Introduction

We can use the Java Virtual Machine (VM) transport for intra-JVM communication between Mule flows. This transport by default uses in-memory queues but can optionally be configured to use persistent queues.

Page 3: Basic example using vm component

FLOW

Page 4: Basic example using vm component

XML:

<?xml version="1.0" encoding="UTF-8"?><mule xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:vm="http://www.mulesoft.org/schema/mule/vm" 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" version="EE-3.4.0" 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.xsdhttp://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsdhttp://www.mulesoft.org/schema/mule/vm http://www.mulesoft.org/schema/mule/vm/current/mule-vm.xsdhttp://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd"> <flow name="VMFlow1" doc:name="VMFlow1"> <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8080" path="VM" doc:name="HTTP"/> <logger message="--Main flow triggered " level="INFO" doc:name="Logger"/> <vm:outbound-endpoint exchange-pattern="request-response" path="subflow" doc:name="VM"/> </flow> <flow name="VMFlow2" doc:name="VMFlow2"> <vm:inbound-endpoint exchange-pattern="request-response" path="subflow" doc:name="VM"/> <logger message="--Hello world" level="INFO" doc:name="Logger"/> </flow></mule>

Page 5: Basic example using vm component

Execution:Service will trigger from URL “http://localhost:8080/VM”Service will display :‘Hello world’

Page 6: Basic example using vm component

The in memory (VM) transport has two modes of operation: One for use with request-response and another for use with one-way endpoints. 

request-response: When using request-response endpoints, messages are delivered directly

from an outbound vm endpoint to the inbound vm endpoint that is listening on the same path. This delivery is blocking and occurs in the same thread. If there is no inbound request-response VM endpoint in the same Mule application that is listening on this path, then dispatching a message from the outbound endpoint fails.

one-way: When using one-way endpoints, messages are delivered to the corresponding

inbound endpoint via a queue. This delivery is non-blocking. If there is no inbound one-wayendpoint in the same Mule application listening on this path, then, although dispatching of the message succeeds, the message remains in the queue. By default, this queue is in memory, but it is also possible to configure a persistent queue that uses the file system as its persistence mechanism.