根據實際需求着重檢查了一下Mule ESB的消息傳遞方式。Mule支持常用的幾種消息傳遞方式,能夠滿足要求。
5. 消息傳遞方式
5.1 異步方式
異步方式是一種單向調用,調用者不需要獲得響應。
圖 Asynchronous
異步方式通過inbound和outbound endpoint的exchange-pattern=”one-way”實現。
使用基本的Stdio Transport驗證,通過標準輸入傳輸字符串,將其原樣傳遞給標準輸出進行顯示。相應配置如下:
<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>
運行服務,控制檯顯示結果如下:
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打印出來的,之後調用服務不會再次顯示。
異步方式適用於簡單的消息傳遞的場景。
轉載:http://my.oschina.net/moon/blog/10881