ESB专题(四)实战mule 3

王朝other·作者佚名  2007-01-18
窄屏简体版  字體: |||超大  

3、 jms provider

因为首先需要一个jms服务器,所以首先我们需要搭建一个jms服务器,这里我们选用了openjms

其使用参考 JMS服务器openJms入门

在conf下创建 配置文件 test-jms-config.xml ,内容如下

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE mule-configuration PUBLIC "-//SymphonySoft //DTD mule-configuration XML V1.0//EN"

"http://www.symphonysoft.com/dtds/mule/mule-configuration.dtd">

<!-- This is the configuration for the Loan Broker ESB example -->

<!-- See http://mule.codehaus.org/LoanBroker for more information, diagrams and even a presentation! -->

<mule-configuration id="Mule_JMS" version="1.0">

<description>

Mule_JMS

</description>

<connector name="jmsConnector" className="org.mule.providers.jms.JmsConnector">

<properties>

<property name="specification" value="1.1"/>

<property name="jndiDestinations" value="true"/>

<property name="forceJndiDestinations" value="true"/>

<property name="connectionFactoryJndiName" value="ConnectionFactory"/>

<property name="jndiInitialFactory" value="org.exolab.jms.jndi.InitialContextFactory"/>

<property name="jndiProviderUrl" value="tcp://localhost:3035"/>

</properties>

</connector>

<transformers>

<transformer name="JMSMessageToString"

className="org.mule.providers.jms.transformers.JMSMessageToObject"

returnClass="java.lang.String" />

<transformer name="HttpRequestToString" className="org.mule.samples.hello.HttpRequestToString"/>

</transformers>

<mule-descriptor name="jmsConnector" implementation="test.Service">

<inbound-router>

<endpoint address="jms://queue1" transformers="JMSMessageToString"/>

</inbound-router>

</mule-descriptor>

</mule-configuration>

在bin下创建批处理文件 testjms.bat ,其内容如下:

@echo off

REM There is no need to call this if you set the MULE_HOME in your environment properties

if "%MULE_HOME%" == "" SET MULE_HOME=..\..

REM Set your application specific classpath like this

SET CLASSPATH=%MULE_HOME%\samples\testmule\conf;%MULE_HOME%\samples\testmule\WebRoot\WEB-INF\classes;

SET CUSTOM_LIB=E:\java\openjms-0.7.7-alpha-3\lib

call %MULE_HOME%\bin\mule.bat -config ../conf/test-jms-config.xml

SET CLASSPATH=

特别注意红字部分,需要指定openjms的lib地址

然后我们启动openjms,再执行 testjms.bat ,然后用openjms的客户端测试工具发送消息,则能看到mule后台监测到的信息,会自动接收到mule里。

其他的如 jdbc,mail,xxmp基本上都是这种思路来实现的,当然要注意transform的配置,因为很多信息需要转换才能正常显示接收的

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有  導航