Mule ESB 学习笔记 异步请求-响应方式
2014-07-02 09:18
411 查看
5.4 异步请求-响应方式
异步请求-响应方式即请求方调用服务后不需要立即获得返回结果,component将请求发送给其他外围系统处理(可能有多个),全部处理完毕后通过指定的异步应答Router返回给请求方。
异步请求-响应方式通过在OutBound Endpoint中增加reply-to以及增加async-reply节点实现,响应配置如下:
cxf-synchronous-request-response.xml
Xml代码
服务器启动并测试:
Java代码
异步请求-响应方式即请求方调用服务后不需要立即获得返回结果,component将请求发送给其他外围系统处理(可能有多个),全部处理完毕后通过指定的异步应答Router返回给请求方。
异步请求-响应方式通过在OutBound Endpoint中增加reply-to以及增加async-reply节点实现,响应配置如下:
cxf-synchronous-request-response.xml
Xml代码
. <?xml version="1.0" encoding="UTF-8"?> <mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:spring="http://www.springframework.org/schema/beans" xmlns:stdio="http://www.mulesoft.org/schema/mule/stdio" xmlns:vm="http://www.mulesoft.org/schema/mule/vm" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:https="http://www.mulesoft.org/schema/mule/https" xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml" xmlns:axis="http://www.mulesoft.org/schema/mule/axis" xmlns:cxf="http://www.mulesoft.org/schema/mule/cxf" xsi:schemaLocation=" http://www.mulesoft.org/schema/mule/stdio http://www.mulesoft.org/schema/mule/stdio/current/mule-stdio.xsd http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.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/vm http://www.mulesoft.org/schema/mule/vm/current/mule-vm.xsd http://www.mulesoft.org/schema/mule/cxf http://www.mulesoft.org/schema/mule/cxf/current/mule-cxf.xsd"> <vm:connector name="vm" numberOfConcurrentTransactedReceivers="1" /> <stdio:connector name="stdioConnector" messageDelayTime="1234" outputMessage="输出信息" promptMessage="输入信息:" /> <model> <service name="async req-rep"> <inbound> <stdio:inbound-endpoint name="in" system="IN" connector-ref="stdioConnector" exchange-pattern="one-way" /> </inbound> <component class="com.easyway.esb.mule.cxf.StdIo" /> <outbound> <multicasting-router> <vm:outbound-endpoint path="async.queue1" exchange-pattern="one-way" /> <vm:outbound-endpoint path="async.queue2" exchange-pattern="one-way" /> <reply-to address="vm://reply" /> </multicasting-router> </outbound> <async-reply timeout="5000" failOnTimeout="true"> <vm:inbound-endpoint path="reply" exchange-pattern="one-way" /> <single-async-reply-router /> </async-reply> </service> </model> </mule>
服务器启动并测试:
Java代码
public class MuleCxfMain { public static void main(String[] args) { try { String configFile = "cxf-synchronous-request-response.xml"; String[] configFileArr = new String[] {configFile }; MuleContextFactory muleContextFactory = new DefaultMuleContextFactory(); MuleContext muleContext = muleContextFactory.createMuleContext(new SpringXmlConfigurationBuilder( configFileArr)); muleContext.start(); } catch (Exception e) { e.printStackTrace(); } } }
相关文章推荐
- java web 学习笔记四 使用ajax响应异步请求
- Mule ESB 学习笔记(2)
- 学习笔记 --- 编码过程中常见的三种异步方式
- IOS学习笔记26—HTTP操作之ASIHTTPRequest(二) 请求-响应
- Mule ESB 学习笔记(2)
- Mule ESB 学习笔记
- ArcIMS学习之 HTML Viewer定制笔记 续二(2.Servlet与请求响应过程)
- SilverLight学习笔记--WebClient异步请求
- php学习笔记(三十)ajax请求和接收参数的实现方式(包括json数据格式的简单处理)
- nodejs 学习笔记---非阻塞请求响应
- Mule ESB 学习笔记
- iOS学习笔记——同步请求下载与异步请求下载
- Mule ESB 学习笔记(4)
- ArcIMS学习之 HTML Viewer定制笔记 续三(3.请求&响应)
- AJAX学习笔记之 客户端请求方式 get 和post 模式
- Mule ESB 学习笔记(5)
- JSP网络编程-请求和响应-HttpServletRequest-HttpServletResponse-学习笔记
- [Erlang 学习笔记]Cowboy 接收 POST 方式的 HTTP 请求
- Mule ESB 学习笔记
- struts2——学习笔记2 通过form表单方式或者js的方式提交请求,封装boolean值的问题