2014-12-04 27 views
1

嗨,我正在與Mule Any Point Studio合作,並且我很想知道它如何與虛擬機和請求 - 回覆作用域協同工作,以便Mule能夠異步處理多個來電到Mule。如何使用虛擬機和請求回覆作用域在Mule中實現消息的並行處理

我只想知道Request-Reply作用域如何在內部工作。在給定的鏈接中,我已經完成了完整的Mule教程。但是我沒有得到正確的工作理念,我是新的蜜蜂。

Request-Reply Scope:

我想使用請求 - 應答範圍使用VM騾子來實現異步並行處理。 對於這個我通過這個鏈接,但我仍然需要更多的光線如何工作。

Blog:

enter image description here

回答

1

request-reply只是發送所接收的消息對所述請求的端點,然後阻塞當前線程,直到消息到達的回覆端點與該相關性id相匹配的相關性id已發送到請求端點。

我們可以總結它作爲異步端點的同步仿真器。在你給的例子中,你可以簡化利用mule回覆頭的相同方法。

+0

所以當我發送消息想這是分配給線程1.現在線程1仍然受阻,直到它會得到的答覆範圍的響應,這意味着.. – Utsav 2014-12-05 06:18:48

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>

相關問題