how to use request reply scope

8
How to use Request Reply Scope 29-05-2015

Upload: sivachandra-mandalapu

Post on 12-Jan-2017

183 views

Category:

Education


2 download

TRANSCRIPT

Page 1: How to use Request Reply scope

How to use Request Reply Scope

29-05-2015

Page 2: How to use Request Reply scope

Abstract

• The main motto of this PPT is How to use Request Reply Scope in our applications.

Page 3: How to use Request Reply scope

Introduction

• The Request-Reply scope enables you to embed a "pocket" of asynchronous processing within a Mule flow. This functionality enables you to receive a response from an asynchronous flow without hardcoding the destination of the response. For example, you can use request-reply to convert a one-way VM or JMS flow to a request-response flow without having to change it’s configuration. In other words, the request-reply converts part of a synchronous process into an asynchronous one.

Page 4: How to use Request Reply scope

Example

Page 5: How to use Request Reply scope

.mflow• <?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" • 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/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:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8097" doc:name="HTTP Listener Configuration"/>• <flow name="RequestReplyFlow">• <http:listener config-ref="HTTP_Listener_Configuration" path="/" doc:name="HTTP"/>• <set-payload doc:name="Set Payload" value="Request"/>• <request-reply doc:name="Request-Reply">• <vm:outbound-endpoint exchange-pattern="one-way" path="req" doc:name="VM"/>• <vm:inbound-endpoint exchange-pattern="one-way" path="res" doc:name="VM"/>• </request-reply>• <logger message="--Final Payload is #[payload]--" level="INFO" doc:name="Logger"/>• </flow>• <flow name="RequestReplyFlow1">• <vm:inbound-endpoint exchange-pattern="one-way" path="req" doc:name="VM"/>• <logger message="--request flow--#[payload]--" level="INFO" doc:name="Logger"/>• <set-payload doc:name="Set Payload" value="#[payload]_Reply"/>• <logger message="--2--#[payload]--" level="INFO" doc:name="Logger"/>• <vm:outbound-endpoint exchange-pattern="one-way" path="res" doc:name="VM"/>• </flow>• </mule>

Page 6: How to use Request Reply scope

• Output:• INFO 2016-05-29 07:15:37,972 [[RequestReply].HTTP_Listener_Configuration.worker.01] org.mule.lifecycle.AbstractLifecycleManager: Initialising:

'connector.VM.mule.default.dispatcher.1445751667'. Object is: VMMessageDispatcher• INFO 2016-05-29 07:15:37,973 [[RequestReply].HTTP_Listener_Configuration.worker.01] org.mule.lifecycle.AbstractLifecycleManager: Starting:

'connector.VM.mule.default.dispatcher.1445751667'. Object is: VMMessageDispatcher• INFO 2016-05-29 07:15:38,006 [[RequestReply].RequestReplyFlow1.stage1.02] org.mule.api.processor.LoggerMessageProcessor: --request flow--Request--• INFO 2016-05-29 07:15:38,008 [[RequestReply].RequestReplyFlow1.stage1.02] org.mule.api.processor.LoggerMessageProcessor: --2--Request_Reply--• INFO 2016-05-29 07:15:38,014 [[RequestReply].RequestReplyFlow1.stage1.02] org.mule.transport.DefaultReplyToHandler: reply to sent:

DefaultOutboundEndpoint{endpointUri=vm://res?connector=connector.VM.mule.default, connector=VMConnector• {• name=connector.VM.mule.default• lifecycle=start• this=705c6b57• numberOfConcurrentTransactedReceivers=4• createMultipleTransactedReceivers=true• connected=true• supportedProtocols=[vm]• serviceOverrides=<none>• }• , name='endpoint.vm.res', mep=ONE_WAY, properties={connector=connector.VM.mule.default}, transactionConfig=Transaction{factory=null,

action=INDIFFERENT, timeout=0}, deleteUnacceptedMessages=false, initialState=started, responseTimeout=10000, endpointEncoding=UTF-8, disableTransportTransformer=false}

• INFO 2016-05-29 07:15:38,015 [[RequestReply].connector.VM.mule.default.dispatcher.01] org.mule.lifecycle.AbstractLifecycleManager: Initialising: 'connector.VM.mule.default.dispatcher.408742592'. Object is: VMMessageDispatcher

• INFO 2016-05-29 07:15:38,015 [[RequestReply].connector.VM.mule.default.dispatcher.01] org.mule.lifecycle.AbstractLifecycleManager: Starting: 'connector.VM.mule.default.dispatcher.408742592'. Object is: VMMessageDispatcher

• INFO 2016-05-29 07:15:38,016 [[RequestReply].connector.VM.mule.default.dispatcher.02] org.mule.lifecycle.AbstractLifecycleManager: Initialising: 'connector.VM.mule.default.dispatcher.1982112397'. Object is: VMMessageDispatcher

• INFO 2016-05-29 07:15:38,016 [[RequestReply].connector.VM.mule.default.dispatcher.02] org.mule.lifecycle.AbstractLifecycleManager: Starting: 'connector.VM.mule.default.dispatcher.1982112397'. Object is: VMMessageDispatcher

• INFO 2016-05-29 07:15:38,022 [[RequestReply].HTTP_Listener_Configuration.worker.01] org.mule.api.processor.LoggerMessageProcessor: --Final Payload is Request_Reply--

Page 7: How to use Request Reply scope

• Flow of execution:1. URL to trigger the service from browserhttp://localhost:80972. A. Flow1 will trigger flow2 with the VM in Request block of Request_Reply scope and with the payload as “Request”.B. Flow2 sets the payload as “Request_Reply” and calls the VM in Reply block of Request_Reply scope in flow1 and at the end POC displays the final payload in console and also returns the same to Browser.