在Mule中采用JMS 传输器进行消息传输,首先要有消息总线的支持,以ActiveMQ为例,详细步骤如下:
1 启动ActiveMQ(详见ActiveMQ)
2 编写发送端配置文件
jms-send-mule-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesource.org/schema/mule/core/2.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jms="http://www.mulesource.org/schema/mule/jms/2.2"
xmlns:http="http://www.mulesource.org/schema/mule/http/2.2"
xmlns:stdio="http://www.mulesource.org/schema/mule/stdio/2.2"
xmlns:https="http://www.mulesource.org/schema/mule/https/2.2"
xsi:schemaLocation="
http://www.mulesource.org/schema/mule/jms/2.2 http://www.mulesource.org/schema/mule/jms/2.2/mule-jms.xsd
http://www.mulesource.org/schema/mule/http/2.2 http://www.mulesource.org/schema/mule/http/2.2/mule-http.xsd
http://www.mulesource.org/schema/mule/https/2.2 http://www.mulesource.org/schema/mule/https/2.2/mule-https.xsd
http://www.mulesource.org/schema/mule/stdio/2.2 http://www.mulesource.org/schema/mule/stdio/2.2/mule-stdio.xsd
http://www.mulesource.org/schema/mule/core/2.2 http://www.mulesource.org/schema/mule/core/2.2/mule.xsd">
<jms:activemq-connector name="jmsQueueConnector" specification="1.0.2b" brokerURL="tcp://localhost:61616"/>
<jms:activemq-connector name="jmsTopicConnector" specification="1.0.2b" brokerURL="tcp://localhost:61616"/>
<stdio:connector name="stdioConnector"
messageDelayTime="1234"
promptMessage="Please enter something: "
/>
<model name="jms102bModel">
<service name="jms102bService">
<inbound>
<stdio:inbound-endpoint system="IN"/>
</inbound>
<outbound>
<pass-through-router>
<jms:outbound-endpoint connector-ref="jmsTopicConnector" topic="backup-reports"/>
</pass-through-router>
</outbound>
</service>
</model>
</mule>
3 编写接收端配置文件
jms-receive-mule-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesource.org/schema/mule/core/2.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jms="http://www.mulesource.org/schema/mule/jms/2.2"
xmlns:stdio="http://www.mulesource.org/schema/mule/stdio/2.2"
xsi:schemaLocation="
http://www.mulesource.org/schema/mule/jms/2.2 http://www.mulesource.org/schema/mule/jms/2.2/mule-jms.xsd
http://www.mulesource.org/schema/mule/core/2.2 http://www.mulesource.org/schema/mule/core/2.2/mule.xsd
http://www.mulesource.org/schema/mule/stdio/2.2 http://www.mulesource.org/schema/mule/stdio/2.2/mule-stdio.xsd">
<jms:activemq-connector
name="jmsConnector"
specification="1.0.2b"
brokerURL="tcp://localhost:61616"/>
<model name="Listing 3.19">
<service name="Backup Reporting Service">
<inbound>
<jms:inbound-endpoint topic="backup-reports" connector-ref="jmsConnector">
<jms:jmsmessage-to-object-transformer/>
</jms:inbound-endpoint>
</inbound>
<outbound>
<pass-through-router>
<stdio:outbound-endpoint system="OUT"/>
</pass-through-router>
</outbound>
</service>
</model>
</mule>
4 分别启动receive和send,发送端输入信息,接收端将会将输入的信息显示到控制台上。
over
分享到:
相关推荐
这是一个使用Netty( )的Mule传输实现,它支持在原始TCP上进行发布/订阅(从较高的角度看,它类似于JMS主题,但是功能有限,例如,不支持事务处理) ,并且没有外部经纪人)。 由Ricston Ltd( )开发。 要从源...
2. **File Transport**: 示例可能展示了如何使用Mule读取或写入文件系统的文件。这对于数据导入导出或文件监控场景非常有用。 3. **JDBC Connector**: Mule可以与数据库交互,示例可能包含连接到数据库并执行查询或...
对于文件和目录的操作,Mule提供了File Transport,使得读写文件、使用过滤器筛选特定类型的文件以及利用标准输入/输出流变得简单易行。 #### 邮件与Web服务 无论是接收或发送邮件,还是消费和暴露Web服务,Mule都...
#### JMS Transport 配置示例 ```xml <jms:connection factory="myConnectionFactory" /> <jms:inbound-endpoint queue="myQueue" connection-factory-ref="myConnectionFactory"/> [message.payload]" level=...
- **Transport(传输):** 提供了各种通信通道,如文件、HTTP、JMS等。 - **Connector(连接器):** 负责特定协议的通信细节,如HTTPConnector、JMSConnector等。 - **Endpoint(端点):** 定义了服务的入口和...
MULE的核心组件包括:传输层(Transport)、数据格式层(Data Format)和消息处理层(Message Processor),它们共同构成了强大的服务集成能力。 **SOA(面向服务的架构)** SOA是一种软件架构模式,它强调将业务...
### Mule (Java) 开发简介 #### 一、Mule 概述 ...这个示例展示了如何使用 Mule 的 XML 配置语法来定义应用程序的不同组件及其交互方式。通过这种方式,开发者可以非常方便地构建和配置自己的集成解决方案。
这部分详细介绍了 Mule 支持的各种传输类型,包括控制台传输、虚拟机传输、文件传输、HTTP 传输、FTP 传输、SMTP 传输和 JMS 传输等,并提供了每种传输的具体配置示例。 #### 第六章:Mule 中的 Web 服务 **概述 ...