1

Hi i am working with Mule Any Point Studio and i am curious to know about how this works with VM and Request-Reply scope so that Mule is able to asynchronously process the multiple incoming calls to Mule.

I just want to know how Request-Reply scope works internally. I have gone through complete Mule Tutorial as mention in the given link. But i didn't get the correct idea of working , i am new bee to this.

Request-Reply Scope:

I want to use Request-Reply Scope to implement the Async Parallel Processing with Mule using VM. For this i went through with this Link but still i need more light on how this works.

Blog:

enter image description here

4

2 回答 2

2

在这里,我尝试使用代码得到了我的问题的答案,请看一下,我正在打印线程 ID,它将清楚地显示它是如何工作的。

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

<mule xmlns:json="http://www.mulesoft.org/schema/mule/json" xmlns:ws="http://www.mulesoft.org/schema/mule/ws" xmlns:vm="http://www.mulesoft.org/schema/mule/vm" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking"
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.5.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.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.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/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.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/ws http://www.mulesoft.org/schema/mule/ws/current/mule-ws.xsd
http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd">
  <flow name="mule-request-replyFlow1" doc:name="mule-request-replyFlow1">
    <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" path="rr" doc:name="HTTP" />
    <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=" Message payload after Outbound  #[message.payload] and Thread is #[Thread.currentThread().getName()] and Thread ID is #[Thread.currentThread().getId()]" level="INFO" doc:name="Logger" />
    <object-to-string-transformer doc:name="Object to String" />
  </flow>
  <flow name="mule-request-replyFlow3" doc:name="mule-request-replyFlow3">

    <vm:inbound-endpoint exchange-pattern="one-way" path="req" doc:name="VM" />
    <http:outbound-endpoint exchange-pattern="request-response" method="GET" address="http://localhost/service/orderservice" doc:name="HTTP" />
    <object-to-string-transformer doc:name="Object to String" />
    <logger message="Response Handler Payload is #[message.payload] and Thread ID is #[Thread.currentThread().getId()]" level="INFO" doc:name="Logger" />
    <vm:outbound-endpoint exchange-pattern="one-way" path="res" doc:name="VM" />
  </flow>
</mule>

于 2014-12-05T14:30:08.643 回答
1

只是将request-reply接收到的消息发送到请求端点,然后阻塞当前线程,直到消息到达回复端点,其相关 id 与发送到请求端点的相关 id 匹配。

我们可以将其概括为异步端点的同步模拟器。在您给出的示例中,您可能可以利用骡子对标题的回复来简化相同的操作。

于 2014-12-04T15:18:27.127 回答