`

实战mule(3)

    博客分类:
  • ESB
阅读更多

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的配置,因为很多信息需要转换才能正常显示接收的

<!--EndFragment-->
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics