mule配置文件元素

<spring:beans>创建spring bean与mule创建的对象一起放在mule的注册信息里。

<spring:beans>
<spring:bean name="globalCache" class="com.mycompany.utils.LRUCache" >
<spring:property name="maxItems" value="200"/>
</spring:bean>
</spring:beans>

<spring:property>mule创建的对象可以spring的属性对象

<custom-processor class="com.mycompany.utils.CustomerClassChecker">
<spring:property name="highPriorities">
<spring:list>
<spring:value>Gold</spring:value>
<spring:value>Platinum</spring:value>
<spring:value>Executive</spring:value>
</spring:list>
</spring:property>
</custom-processor>

mule可以使用spring属性

<spring:beans>
<context:property-placeholder
location="classpath:my-mule-app.properties,
classpath:my-mule-app-override.properties" />
</spring:beans>


<http:endpoint name="ProtectedWebResource"
user="${web.rsc.user}"
password="${web.rsc.password}"
host="${web.rsc.host}"
port="80"
path="path/to/resource" />

Properties file:


web.rsc.user=alice
web.rsc.password=s3cr3t
web.rsc.host=www.acme.com

 

Connectors

mule具体的传输对象

 

mule endpoint可以指定connectors这样endpoint与connector分离非常灵活

endpoint只能有一个connector

如果endpoint没指定connector mule将会为其创建connector

<vm:connector name="persistentConnector">
<vm:queueProfile persistent="true" />
</vm:connector>


<file:connector name="fileConnector"
pollingFrequency="1000" moveToDirectory="/tmp/test-data/out" />

 

Endpoints

mule的一个对象可以读取信息或写入信息,其中的属性定义怎样处理消息

 

<vm:endpoint name="in" address="vm://in" connector-ref="persistentConnector" />
<http:endpoint name="in" host="localhost" port="8080" path = "services/orders" />
<endpoint name="inFiles" address="file://c:/Orders" />

 

Transformers

转换当前mule信息

 

<json:json-to-object-transformer
name="jsonToFruitCollection" returnClass="org.mule.module.json.transformers.FruitCollection">
<json:deserialization-mixin
mixinClass="org.mule.module.json.transformers.OrangeMixin" targetClass="org.mule.tck.testmodels.fruit.Orange"/>
</json:json-to-object-transformer>


<message-properties-transformer name="SetInvocationProperty" scope="invocation">
<add-message-property key="processed" value="yes" />
</message-properties-transformer>

 

Filters

过滤信息是否被处理

 

<wildcard-filter pattern="* header received"/>
只有匹配指定的pattern的信息才被处理
<mxml:is-xml-filter/>

只处理xml

<message-filter onUnaccepted="deadLetterQueue"> ❶
<wildcard-filter pattern="* header received"/>
</message-filter>


<message-filter throwOnUnaccepted="true"> ❷
<mxml:is-xml-filter/>
</message-filter>

可以嵌套

<or-filter>
<wildcard-filter pattern="*priority:1*"/>
<and-filter>
<not-filter>
<wildcard-filter pattern="*region:Canada*"/>
</not-filter>
<wildcard-filter pattern="*priority:2*"/>
</and-filter>
</or-filter>

嵌套加入条件

 

Expressions

mule表达式,可以用来判断或影响mule的行为

 

<expression-filter evaluator="header" expression="my-header!=null"/>

在值中利用表达式的值#[evaluator:expression]

<message-properties-transformer>
<add-message-property name="GUID" value="#[string:#[xpath:/msg/header/ID]-#[xpath:/msg/body/@ref]]"/>
</message-properties-transformer>

Names and References

用于指定全局对象并且复用

vm:endpoint name="in" address="vm://in" connector-ref="persistentConnector" />
<expression-filter name=checkMyHeader" evaluator="header" expression="my-header!
<message-properties-transformer name="SetInvocationProperty" scope="invocation">
<add-message-property key="processed" value="yes" />
</message-properties-transformer>


<flow name="useReferences">
<vm:inbound-endpoint ref="in"/>
<filter ref="checkSetInvocationPropertyMyHeader"/>
<transformer ref=""/>
</flow>

 

Flows

最基本的mule处理单元,开始于一个inbound endpoint接着是一系列的处理与可选择的outbound endpoint

 

<flow name="acceptAndProcessOrder">
<http:inbound-endpoint ref="in"/> ❶
<byte-array-to-string-transformer/> ❷
<jdbc:outbound-endpoint ref="getOrdersById" exchange-pattern="request-response"/> ❸
<mxml:object-to-xml-transformer/> ❹
<expression-filter evaluator="xpath" expression="/status = 'ready'/>❺
<logger level="DEBUG" message="fetched orders: #[payload]"/> ❻
<splitter evaluator="xpath" expression="/order"/> ➐


<enricher> ❽
<authorize:authorization-and-capture amount="#[xpath:/amount]" ❾
cardNumber="#[xpath:/card/number]"
expDate="#[xpath:/card/expire]" />
<enrich target="#[variable:PaymentSuccess]" source="#[bean:responseCode]"/>
</enricher>
<message-properties-transformer scope=:invocation"> ❶❶
<add-message-property key"user-email-address" value="[xpath:/user/email]"/>
</message-properties-transformer>
<component class="org.mycompany.OrderPreProcessor"/> ❶❷
<flow-ref name="processOrder"/> ❶❸
<smtp:outbound-endpoint subject="Your order has been processed" to="#[header:INVOCATION:user-email-address]/> ❶❹


<default-exception-strategy> ❶❺
<processor-chain> ❶❻
<object-to-string-transformer/> ❶➐
<jms:outbound-endpoint ref="order-processing-errors"/> ❶❽
</processor-chain/>
</default-exception-strategy>
</flow>

 

 

Routers
消息路由
Components
mule信息处理者,默认是java实现,可以为其他语言
<component class="org.mycompany.OrderPreProcessor"> ❶
<entry-point-resolver-set>
<method-entry-point-resolver>
<include-entry-point method="preProcessXMLOrder" />
<include-entry-point method="preProcessTextOorder" />
</method-entry-point-resolver>
<reflection-entry-point-resolver/>
</entry-point-resolver-set>
</component>


<component class="org.mycompany.OrderPreProcessor"> ❷
<property-entry-point-resolver property="methodToCall"/>
</component>


<component class="org.mycompany.generateDefaultOrder"> ❸
<no-arguments-entry-point-resolver>
<include-entry-point method="generate"/>
</no-arguments-entry-point-resolver>
</component>
Cloud Connectors
调用云服务
Processor Chain
信息处理链
Sub-flow
调用其他flow的flow
Bridge
连接inbound endpoint与outbound endpoint
<pattern:bridge name="queue-to-topic" ❶
transacted="true"
inboundAddress="jms://myQueue"
outboundAddress="jms://topic:myTopic" />


<pattern:bridge name="transforming-bridge" ❷
inboundAddress="vm://transforming-bridge.in"
transformer-refs="byte-array-to-string"
responseTransformer-refs="string-to-byte-array"
outboundAddress="vm://echo-service.in" />
Simple Service
引用其他component提供服务
<pattern:simple-service name="echo-service" ❶
endpoint-ref="echo-service-channel"
component-class="com.mycompany.EchoComponent" />




<pattern:simple-service name="weather-forecaster-ws" ❷
address="http://localhost:6099/weather-forecast"
component-class="com.myompany.WeatherForecaster"
type="jax-ws" />
Web service proxy

创建一个web service 代理
<pattern:web-service-proxy name="weather-forecast-ws-proxy"
inboundAddress="http://localhost:8090/weather-forecast"
outboundAddress="http://server1:6090/weather-forecast"
wsdlLocation="http://server1:6090/weather-forecast?wsdl" />

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值