版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1Mule-config.xml示例模型:<mule><model><servicename="GreeterUMO"><inbound....><filtering-router>....</filtering-router></inbound>〈component..../><outbound....></outbound><default-service-exception-strategy></default-service-exception-strategy></service><servicename="GreeterUMO2"initialState="stopped">...</service></model> </mule> 1.1基本标签Mule配置文件由以下标签组织成一颗XML元素树:<model>定义应用程序中的服务;<service>配置一个服务;<description>服务的描述内容;<inbound>配置入站路由,它们的端点以及入站转换器;<outbound>配置一个或多个出站路由,它们的端点以及出站转换器;<async-reply>配置一个异步应答路由,它用于异步请求/响应消息中;<exception-strategy>配置连接器或模型或服务上的错误处理策略;1.2配置设置将服务组件编织成一个应用程序是由配置文件来完成的,Mule的配置设置是由开发人员负责的,它们包括:1、服务组件的声明;2、哪个服务上的端点将接收消息;3、将消息引入到服务组件之前使用哪个转换器4、 出站端点上的消息下一步改流向哪里;5、 消息的路由信息将其发送到下一个服务组件。1.3声明服务组件<component>Mule组件是通过指定实施类名配置的,Mule为组件接收的每个消息创建新的类实例,注意是一个特定的Java类而不是函数:<componentclass="org.my.ServiceComponentImpI"/><pooled-component>Mule创建一批组件,共用组件配置,对象工厂创建一个单一的对象实例也可以指定:<pooled-componentclass="org.my.ServiceComponentImpI"/><component><singleton-objectclass="org.my.ServiceComponentImpI"/> 〈/component〉 <entry-point-resolver-set/>Mule可以创建一个入口点分解器基于消息负载情况动态选择调用的函数:<componentclass="org.my.PrototypeObjectWithMyLifecycIe"><entry-point-resolver-set><array-entry-point-resolver/><callable-entry-point-resolver/></entry-point-resolver-set> </component> <callable-entry-point-resolver>这个入口点分解器用于组件实现org.mule.api.lifecycle.Callable接口,组件可以实现Callable接口废除一切动态解决方案,并调用接口函数进行替代;<custom-entry-point-resolver-set>这个自定义入口点分解器可以和实现了org.mule.api.model.EntryPointResolverSet接口的类一起实施,为了准确地在你的端点上指定函数,你可以在端点上使用函数参数,如:<ejb:endpointhost="localhost"port="1099"object="SomeService' method="remoteMethod"/> <log-component/>Mule提供了多个简单有用的组件用于测试和初始化原型,如<log-component/>,它将所有接收到的消息输出到控制台中;1.4配置端点<endpoint>使用它声明一个全局范围的端点,在整个Mule应用程序中都可以使用,在一个服务中,"ref=”用于引用全局端点:<file:endpointname="fileReader"reverseOrder="true"comparator="parator.OlderFirstComparator"/><model><servicename="Priority1"><file:inbound-endpointref="fileReader"path="/var/prio1"/></service><servicename="Priority2"><file:inbound-endpointref="fileReader"path="/var/prio2"/></service> </model> <inbound-endpoint>这是服务组件接收事件的通道,它包括使用的传输器,地址,路径或资源(任何有效的URI):<inbound-endpointaddress="udp://localhost:65432"/><inbound-endpointaddress="jms://test.queue"/><outbound-endpoint>这个是组件返回的数据被发送出去的通道;<outbound-endpointaddress="smtp://user:secret@smtp.host"/><outbound-endpointaddress="smtp://user:secret@smtp.host"/>1.5配置入站路由<selective-consumer-router>这个路由在入站消息上应用一个或多个过滤器,符合要求的消息被转送到组件:<inbound><selective-consumer-router><mulexml:jxpath-filterexpression="msg/header/resultcode='success'"/></selective-consumer-router><forwarding-catch-all-strategy><jms:endpointtopic="error.topic"/></forwarding-catch-all-strategy> </inbound> <idempotent-receiver-router>这个路由通过检查入站消息的唯一性消息ID确保服务接收的消息是唯一性的,ID可以使用idExpression属性中定义的表达式生成:<inbound><secure-hash-idempotent-receiver-routermessageDigestAlgorithm="SHA26'><simple-text-file-storedirectory="./idempotent"/></secure-hash-idempotent-receiver-router> </inbound> <secure-hash-idempotent-receiver>这个路由通过计算消息内容的散列值确保服务接收到的消息的唯一性:<inbound><secure-hash-idempotent-receiver-routermessageDigestAlgorithm="SHA26'><simple-text-file-storedirectory="./idempotent"/></secure-hash-idempotent-receiver-router> </inbound> 1.6配置出站路由<filtering-router>这个路由使用过滤器确定消息是否匹配特定的标准;<outboundmatchAll="true"><filtering-router><endpointaddress="jms://deposit.queue"/></filtering-router><filtering-router><jms:outbound-endpointqueue="large.deposit.queue"/><mulexml:jxpath-filterexpression="deposit/amount>=100000"/></filtering-router> </outbound> <pass-through-router>这个路由匹配所有的消息,通过一个配置好的端点发送出去;<outbound><pass-through-router><smtp:outbound-endpointto="ross@"/></pass-through-router> </outbound> 1.6.3<static-recipient-list-router>这个路由用于从单个端点发送相同的消息到多个端点,或实施消息属性或有效负载确定的下一个目的地的路由滑动行为;<outbound><static-recipient-list-router><payload-type-filterexpectedType="javax.jms.Message"/><recipients><spring:value>jms://orders.queue</spring:value><spring:value>jms://tracking.queue</spring:value></recipients></static-recipient-list-router> </outbound> 1.7配置传输器和连接器以为传输器声明一个描述连接信息的端点URI的值:<rmi:endpointname="BadType"host="localhost"port="1099"object="MatchingUMO"method="reverseString"/><jms:inbound-endpointqueue="test.queue"/><ssl:endpointname="clientEndpoint"host="localhost"port="60198'synchronous="true"/><quartz:endpointname="qEP6"repeatCount="10" repeatInterval="伽,"jcbNama/cb"/> 同样,可以使用<connector>元素定义一个连接器配置,Mule使用标准的组件,如WorkManager高效共享线程资源,并为线程使用提供更多控制,对于错误,你也要象事务行为一样声明一个异常策略:<vm:connectorname="VMConnector'>■■■<default-connector-exception-strategy><vm:outbound-endpointpath="systemErrorHandler"/></default-connector-exception-strategy> </vm・connector> 1.8配置转换器可以配置一个本地或全局的转换器,本地转换器定义在端点上,而全局转换器是在需要的时候进行引用的,下面的代码定义了两个全局转换器:<xm:xml-to-object-transformername="XMLToExceptionBean"returnClass="org.mule.example.errorhandler.ExceptionBean"/><custom-transformername="ExceptionBeanToErrorMessage"class="org.mule.example.errorhandler.ExceptionBeanToErrorMessage returnClass="org.mule.example.errorhandler.ErrorMessage"/><append-string-transformer>在现有的字符串上追加了一个字符串:<append-string-transformername="myAppender' message="...that'sgoodtoknow!”
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 剪纸工作室工作制度
- 人才服务站工作制度
- 三进四同步工作制度
- 义务护校队工作制度
- 办公室经理工作制度
- 动物救护站工作制度
- 化工厂取样工作制度
- 区电子政务工作制度
- 医务委员会工作制度
- 医用影像科工作制度
- 2026年见证取样员模拟题库讲解附参考答案详解【综合题】
- 2026年中国储备粮管理集团有限公司招聘81人笔试历年常考点试题专练附带答案详解
- 2024年公安机关理论考试题库500道附参考答案(考试直接用)
- (高清版)JTGT M72-01-2017 公路隧道养护工程预算定额
- 质量保证体系图
- 钱钟书《吃饭》赏析
- 检验常用名词缩写中英文对照大全医学检验专业词汇省写
- 广东省营造林工程定额与造价
- 说课《建筑装饰施工技术》 课件
- 中药学电子版教材
- 基于学科核心素养的学业质量水平
评论
0/150
提交评论