根据实际需求着重检查了一下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打印出来的,之后调用服务不会再次显示。
异步方式适用于简单的消息传递的场景。
to be continued...