Mule ESB 學習筆記(4)

5.2 請求-響應方式

請求-響應方式即請求方調用服務後,服務立即處理並返回響應結果,不需將消息再次傳遞。

圖 Request-Response

請求-響應方式通過input endpointexchange-pattern=”request-response”實現,相應配置如下:

<model name="services">    
    <service name="echoService">    
        <inbound>    
            <inbound-endpoint address="http://localhost:7007/services/Echo"    
                exchange-pattern="request-response">    
                <cxf:jaxws-service />    
            </inbound-endpoint>    
        </inbound>    
        <component>    
            <singleton-object class="demo.mule.umo.Echo" />    
        </component>    
    </service>    
</model>

上邊是通過service配置的,通過flow配置如下:

<flow name="EchoFlow">    
    <inbound-endpoint address="http://localhost:7007/services/Echo"    
        exchange-pattern="request-response" />    
    <cxf:jaxws-service serviceClass="demo.mule.umo.Echo" />    
    <component>    
        <singleton-object class="demo.mule.umo.Echo" />    
    </component>    
</flow>

在瀏覽器中輸入“http://localhost:7007/services/Echo/echo/text/hello,world”,瀏覽器中會顯示“hello,world”的輸出信息。

請求-響應方式適用於單次服務調用的場景。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章