VM Transport

VM Transport

VM transport用于Mule管理的组件之间的内部通讯,该连接器提供了用于配置VM瞬态或持久队列选项,Javadoc查看here .

使用VM队列(Using VM Queues)

当使用同步的VM Endpoint的时候,信息将在内存中从一个组件传递到内一个组件(异步endpoint可以从引入的队列中使用)。

不过设置了queueEvents属性值,消息能够被存储在任意内存队列中,过后可被客户端或者组件所使用,此外,这些队列能够被

持久化或者XA事务(参考以下例子)。

使用VM队列的时候,queueEvents属性必须被设置在connector中,并且所有的VM endpoints的队列消息必须使用已经启用了

queueEvents的VM connector。你不能将queueEvents设置在endpoint中,如下示例:

<?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:vm="http://www.mulesoft.org/schema/mule/vm"
xmlns:test="http://www.mulesoft.org/schema/mule/test"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.0/mule.xsd
http://www.mulesoft.org/schema/mule/test http://www.mulesoft.org/schema/mule/test/3.0/mule-test.xsd
http://www.mulesoft.org/schema/mule/vm http://www.mulesoft.org/schema/mule/vm/3.0/mule-vm.xsd">

<vm:connector name="asynchVm" queueEvents="true"/>
<model>
<service name="myAsynchService">
<inbound>
<vm:inbound-endpoint path="in" connector-ref="asynchVm"/>
</inbound>

<test:component>
<test:return-data>Polo</test:return-data>
</test:component>

<outbound>
<pass-through-router>
<vm:outbound-endpoint path="out" connector-ref="asynchVm"/>
</pass-through-router>
</outbound>
</service>
</model>
</mule>
注意inbound endpoint明确指定了Mule使用asynchVm connector,否则,Mule将查找第一个满足endpoint协议的connector。
队列中的更多配置信息,请查看Configuring Queues
使用持久化队列(Using Persistent Queues)
一个VM队列能够被持久化以至于它的状态能在server关掉之间得于维护,为了使VM队列能够被持久化,你必须在你的model或者
service中配置queue profile的persistent属性可用,请注意队列能够被持久化或者事务化,但是两者不可以同时进行。
设置connector配置如下:
<vm:connector name="persistent">
  
<vm:queue-profile persistent="true" maxOutstandingMessages="500"/>
</vm:connector>

使用事务(Using Transactions)

一个瞬态的VM 队列能够参与分布式XA 事务,为了实现VM 队列事务,必须配置如下:

<inbound>
<vm:inbound-endpoint address="vm://dispatchInQueue" connector-ref="vmQueue">
<vm:transaction action="BEGIN_OR_JOIN"/>
</vm:inbound-endpoint>
</inbound>
你可以在你的配置中添加事务管理,更多详细信息请参考Transaction Management.
通过CXF使用VM(Using VM with CXF)

你可以通过CXF进行VM传输以便于支持web service集成,为了创建一个VM/CXF endpoint,你需要申明CXF的schema和

它的namespace,配置connector和endpoints如下:

<cxf:connector name="cxf" defaultFrontend="simple"/>
<model name="test">
<service name="mycomponent">
<inbound>
<inbound-endpoint address="cxf:vm://mycomponent"/>
</inbound>
<component>
<singleton-object class="org.mule.tck.testmodels.services.TestServiceComponent"/>
</component>
</service>
<service name="httpBridge">
<inbound>
<inbound-endpoint address="http://localhost:63081/test" synchronous="true"/>
</inbound>
<outbound>
<chaining-router>
<outbound-endpoint address="vm://mycomponent"/>
</chaining-router>
</outbound>
</service>
</model>
转换器(Transformers)
没有什么具体的转换器使用于VM 传输
配置参考(Configuration Reference)

Connector

<connector...>属性

Name Type Required Default Description
queueTimeout positiveInteger no   The timeout setting for the queue used for asynchronous endpoints

<connector...>子元素

Name Cardinality Description
queueProfile 0..1 DEPRECATED. USE "<queue-profile>" instead.
queue-profile 0..1 Configures the properties of this connector's queue (see Configuring Queues).

Inbound Endpoint

<inbound-endpoint...>

Name Type Required Default Description
path string no   The queue path, such as dispatchInQueue to create the address vm://dispatchInQueue.

Outbound Endpoint

<outbound-endpoint...>

Name Type Required Default Description
path string no   The queue path, such as dispatchInQueue to create the address vm://dispatchInQueue.

Endpoint

<endpoint...>属性

Name Type Required Default Description
path string no   The queue path, such as dispatchInQueue to create the address vm://dispatchInQueue.

事务(Transaction)

transaction元素用来配置事务,它允许一系列的操作在一个事务中当一个出现失败的时候集体回滚,更多信息请参考Transaction Management
posted @ 2011-04-01 15:50  wuwenyu  阅读(512)  评论(0)    收藏  举报