根據實際需求着重檢查了一下Mule ESB的消息傳遞方式。Mule支持經常使用的幾種消息傳遞方式,可以知足要求。異步
5. 消息傳遞方式spa
5.1 異步方式code
異步方式是一種單向調用,調用者不須要得到響應。component
圖 Asynchronousrouter
異步方式經過inbound和outbound endpoint的exchange-pattern=」one-way」實現。字符串
使用基本的Stdio Transport驗證,經過標準輸入傳輸字符串,將其原樣傳遞給標準輸出進行顯示。相應配置以下:it
<service name="echo"> <inbound> <stdio:inbound-endpoint system="IN" exchange-pattern="one-way" /> </inbound> <component> <singleton-object class="demo.mule.umo.StdIo" /> </component> <outbound> <pass-through-router> <stdio:outbound-endpoint system="OUT" exchange-pattern="one-way" /> </pass-through-router> </outbound> </service>
運行服務,控制檯顯示結果以下:io
Please enter: Hello, world! INFO 2010-12-07 19:21:18,877 [ConsoleConnector.dispatcher.1] org.mule.lifecycle.AbstractLifecycleManager: Initialising: 'ConsoleConnector.dispatcher.23255376'. Object is: StdioMessageDispatcher INFO 2010-12-07 19:21:18,877 [ConsoleConnector.dispatcher.1] org.mule.lifecycle.AbstractLifecycleManager: Starting: 'ConsoleConnector.dispatcher.23255376'. Object is: StdioMessageDispatcher Hello, world!
其中INFO輸出是Mule第一次初始化相應Connector打印出來的,以後調用服務不會再次顯示。class
異步方式適用於簡單的消息傳遞的場景。配置
to be continued...