MULE2.0升级(二)配置更新
修改为mule2.0后,MULE的配置做了比较大的变动
原来的email-config.xml文件修改如下:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesource.org/schema/mule/core/2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:file="http://www.mulesource.org/schema/mule/file/2.0"
xmlns:jms="http://www.mulesource.org/schema/mule/jms/2.0"
xmlns:smtp="http://www.mulesource.org/schema/mule/smtp/2.0"
xmlns:pop3="http://www.mulesource.org/schema/mule/pop3/2.0"
xmlns:email="http://www.mulesource.org/schema/mule/email/2.0"
xmlns:xm="http://www.mulesource.org/schema/mule/xml/2.0"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.mulesource.org/schema/mule/core/2.0 http://www.mulesource.org/schema/mule/core/2.0/mule.xsd
http://www.mulesource.org/schema/mule/file/2.0 http://www.mulesource.org/schema/mule/file/2.0/mule-file.xsd
http://www.mulesource.org/schema/mule/jms/2.0 http://www.mulesource.org/schema/mule/jms/2.0/mule-jms.xsd
http://www.mulesource.org/schema/mule/smtp/2.0 http://www.mulesource.org/schema/mule/smtp/2.0/mule-smtp.xsd
http://www.mulesource.org/schema/mule/pop3/2.0 http://www.mulesource.org/schema/mule/pop3/2.0/mule-pop3.xsd
http://www.mulesource.org/schema/mule/email/2.0 http://www.mulesource.org/schema/mule/email/2.0/mule-email.xsd
http://www.mulesource.org/schema/mule/xml/2.0 http://www.mulesource.org/schema/mule/xml/2.0/mule-xml.xsd">
<description>MULE2.0.2 MAIL2JMS2</description>
<!-- 载入配置文件 -->
<context:property-placeholder location="email2jms2.properties" />
<custom-transformer name="EmailMessageToMessageBean"
class="com.megaeyes.transforms.EmailMessageToMessageBean" />
<xm:object-to-xml-transformer name="BeanToXML"
returnClass="java.lang.String" />
<!-- activemq 连接 -->
<jms:activemq-connector name="JMSConnector"
brokerURL="${activeMQ.url}" />
<!-- 文件 连接 -->
<file:connector name="FileConnector" outputAppend="true" />
<model name="Mail2Jms2">
<service name="EmailBridge">
<inbound>
<pop3:inbound-endpoint user="${pop3.username}"
password="${pop3.password}" host="${pop3.host}" port="${pop3.port}"
transformer-refs="EmailMessageToMessageBean" encoding="${basic.encoding}">
<properties>
<spring:entry key="checkFrequency"
value="${email.checkFrequency}" />
<spring:entry key="deleteReadMessages"
value="${email.deleteReadMessages}" />
</properties>
</pop3:inbound-endpoint>
</inbound>
<component
class="com.megaeyes.service.impl.EmailManagerImpl" />
<outbound>
<multicasting-router>
<file:outbound-endpoint path="${logFile.path}"
outputPattern="${logFile.name}" encoding="${basic.encoding}"
connector-ref="FileConnector" transformer-refs="BeanToXML">
</file:outbound-endpoint>
<outbound-endpoint address="jms://ConnectionFactory"
connector-ref="JMSConnector" />
</multicasting-router></outbound>
</service>
</model>
</mule>
配置文件email2jms2.properties,配置独立,修改更为方便
#===============================
# basic configuration
#===============================
basic.encoding=UTF-8
#=================================
# email configuration
#=================================
pop3.host=192.168.10.253
pop3.port=110
pop3.username=kiko
pop3.password=kiko
email.checkFrequency=10000
email.deleteReadMessages=true
#=================================
# activeMQ configuration
#=================================
activeMQ.url=tcp\://192.168.10.253\:61616
#================================
# log file configuration
#================================
logFile.path=d:/logs
logFile.name=log.xml
由于这次更新的项目用MAVEN管理
所以还有两个配置文件
pom.xml如下:
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.megaeyes</groupId>
<artifactId>Mail2Jms2</artifactId>
<packaging>war</packaging>
<name/>
<version>0.0.1-SNAPSHOT</version>
<description/>
<dependencies>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.4</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.9</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>org.mule</groupId>
<artifactId>mule-core</artifactId>
<version>2.0.2</version>
</dependency>
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-core</artifactId>
<version>4.1.1</version>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.mule.transports</groupId>
<artifactId>mule-transport-jms</artifactId>
<version>2.0.2</version>
</dependency>
</dependencies>
</project>
打包文件build.xml如下:
<!-- modified by sillycat.luohua 2008.06.27 -->
<project name="Mail2Jms2" default="compile" basedir=".">
<!-- set global properties for this build -->
<!-- 项目名字 -->
<property name="project" value="Mail2Jms2" />
<!-- 源代码路径 -->
<property name="src" location="src/java" />
<!-- 所有的配置文件 -->
<property name="config" location="src/conf" />
<!-- web项目的根 -->
<property name="web" location="WebRoot" />
<!-- web中用到的jar包 -->
<property name="web-lib" location="${web}/WEB-INF/lib" />
<!-- build出class的路径 -->
<property name="build" location="build" />
<!-- 生成jar包和项目部署配置文件的路径 -->
<property name="dist" location="dist" />
<!-- maven管理的jar包 -->
<property name="maven-jar" location="target/dependency" />
<!-- 编译项目的classpath设置 -->
<path id="classpath.compile">
<fileset dir="${web-lib}">
<include name="**/*.jar" />
</fileset>
<pathelement path="${build}" />
</path>
<target name="init">
<!-- 编译前先生成目录 -->
<mkdir dir="${build}" />
<mkdir dir="${dist}" />
<copy todir="${web-lib}">
<fileset dir="${maven-jar}" includes="*.jar">
</fileset>
</copy>
</target>
<target name="compile" depends="init" description="compile the source">
<mkdir dir="${build}/classes" />
<!-- Compile the java code from ${src} into ${build} -->
<javac srcdir="${src}" destdir="${build}/classes" debug="true" deprecation="true" optimize="false" failοnerrοr="true" encoding="utf-8">
<classpath refid="classpath.compile" />
</javac>
</target>
<!-- 打成jar包 -->
<target name="jarRelease">
<jar destfile="${dist}/Mail2Jms2.jar" basedir="${build}/classes" includes="com/megaeyes/**" />
</target>
<!-- 拷贝配置资源给本机测试用 -->
<target name="config4debug">
<copy file="${config}/email-config.xml" tofile="${dist}/email-config.xml" />
<copy file="${config}/email2jms2.properties" tofile="${dist}/email2jms2.properties" />
</target>
<!-- release -->
<target name="jar" depends="clean,compile,config4debug,jarRelease" description="generate the war package for personal debug">
</target>
<!-- 编译打包前先清空 -->
<target name="clean" description="clean up">
<!-- Delete the ${build} and ${dist} directory trees -->
<delete dir="${build}" />
<delete dir="${dist}" />
</target>
</project>
拷贝jar包只用执行
mvn clean dependency:copy-dependencies
打包执行
ant jar
打包没有把依赖的jar包打入,这些jar包拷贝到mule2.0的lib/usr下面就行了,不要打包到自己的项目里面
修改为mule2.0后,MULE的配置做了比较大的变动
原来的email-config.xml文件修改如下:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesource.org/schema/mule/core/2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:file="http://www.mulesource.org/schema/mule/file/2.0"
xmlns:jms="http://www.mulesource.org/schema/mule/jms/2.0"
xmlns:smtp="http://www.mulesource.org/schema/mule/smtp/2.0"
xmlns:pop3="http://www.mulesource.org/schema/mule/pop3/2.0"
xmlns:email="http://www.mulesource.org/schema/mule/email/2.0"
xmlns:xm="http://www.mulesource.org/schema/mule/xml/2.0"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.mulesource.org/schema/mule/core/2.0 http://www.mulesource.org/schema/mule/core/2.0/mule.xsd
http://www.mulesource.org/schema/mule/file/2.0 http://www.mulesource.org/schema/mule/file/2.0/mule-file.xsd
http://www.mulesource.org/schema/mule/jms/2.0 http://www.mulesource.org/schema/mule/jms/2.0/mule-jms.xsd
http://www.mulesource.org/schema/mule/smtp/2.0 http://www.mulesource.org/schema/mule/smtp/2.0/mule-smtp.xsd
http://www.mulesource.org/schema/mule/pop3/2.0 http://www.mulesource.org/schema/mule/pop3/2.0/mule-pop3.xsd
http://www.mulesource.org/schema/mule/email/2.0 http://www.mulesource.org/schema/mule/email/2.0/mule-email.xsd
http://www.mulesource.org/schema/mule/xml/2.0 http://www.mulesource.org/schema/mule/xml/2.0/mule-xml.xsd">
<description>MULE2.0.2 MAIL2JMS2</description>
<!-- 载入配置文件 -->
<context:property-placeholder location="email2jms2.properties" />
<custom-transformer name="EmailMessageToMessageBean"
class="com.megaeyes.transforms.EmailMessageToMessageBean" />
<xm:object-to-xml-transformer name="BeanToXML"
returnClass="java.lang.String" />
<!-- activemq 连接 -->
<jms:activemq-connector name="JMSConnector"
brokerURL="${activeMQ.url}" />
<!-- 文件 连接 -->
<file:connector name="FileConnector" outputAppend="true" />
<model name="Mail2Jms2">
<service name="EmailBridge">
<inbound>
<pop3:inbound-endpoint user="${pop3.username}"
password="${pop3.password}" host="${pop3.host}" port="${pop3.port}"
transformer-refs="EmailMessageToMessageBean" encoding="${basic.encoding}">
<properties>
<spring:entry key="checkFrequency"
value="${email.checkFrequency}" />
<spring:entry key="deleteReadMessages"
value="${email.deleteReadMessages}" />
</properties>
</pop3:inbound-endpoint>
</inbound>
<component
class="com.megaeyes.service.impl.EmailManagerImpl" />
<outbound>
<multicasting-router>
<file:outbound-endpoint path="${logFile.path}"
outputPattern="${logFile.name}" encoding="${basic.encoding}"
connector-ref="FileConnector" transformer-refs="BeanToXML">
</file:outbound-endpoint>
<outbound-endpoint address="jms://ConnectionFactory"
connector-ref="JMSConnector" />
</multicasting-router></outbound>
</service>
</model>
</mule>
配置文件email2jms2.properties,配置独立,修改更为方便
#===============================
# basic configuration
#===============================
basic.encoding=UTF-8
#=================================
# email configuration
#=================================
pop3.host=192.168.10.253
pop3.port=110
pop3.username=kiko
pop3.password=kiko
email.checkFrequency=10000
email.deleteReadMessages=true
#=================================
# activeMQ configuration
#=================================
activeMQ.url=tcp\://192.168.10.253\:61616
#================================
# log file configuration
#================================
logFile.path=d:/logs
logFile.name=log.xml
由于这次更新的项目用MAVEN管理
所以还有两个配置文件
pom.xml如下:
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.megaeyes</groupId>
<artifactId>Mail2Jms2</artifactId>
<packaging>war</packaging>
<name/>
<version>0.0.1-SNAPSHOT</version>
<description/>
<dependencies>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.4</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.9</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>org.mule</groupId>
<artifactId>mule-core</artifactId>
<version>2.0.2</version>
</dependency>
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-core</artifactId>
<version>4.1.1</version>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.mule.transports</groupId>
<artifactId>mule-transport-jms</artifactId>
<version>2.0.2</version>
</dependency>
</dependencies>
</project>
打包文件build.xml如下:
<!-- modified by sillycat.luohua 2008.06.27 -->
<project name="Mail2Jms2" default="compile" basedir=".">
<!-- set global properties for this build -->
<!-- 项目名字 -->
<property name="project" value="Mail2Jms2" />
<!-- 源代码路径 -->
<property name="src" location="src/java" />
<!-- 所有的配置文件 -->
<property name="config" location="src/conf" />
<!-- web项目的根 -->
<property name="web" location="WebRoot" />
<!-- web中用到的jar包 -->
<property name="web-lib" location="${web}/WEB-INF/lib" />
<!-- build出class的路径 -->
<property name="build" location="build" />
<!-- 生成jar包和项目部署配置文件的路径 -->
<property name="dist" location="dist" />
<!-- maven管理的jar包 -->
<property name="maven-jar" location="target/dependency" />
<!-- 编译项目的classpath设置 -->
<path id="classpath.compile">
<fileset dir="${web-lib}">
<include name="**/*.jar" />
</fileset>
<pathelement path="${build}" />
</path>
<target name="init">
<!-- 编译前先生成目录 -->
<mkdir dir="${build}" />
<mkdir dir="${dist}" />
<copy todir="${web-lib}">
<fileset dir="${maven-jar}" includes="*.jar">
</fileset>
</copy>
</target>
<target name="compile" depends="init" description="compile the source">
<mkdir dir="${build}/classes" />
<!-- Compile the java code from ${src} into ${build} -->
<javac srcdir="${src}" destdir="${build}/classes" debug="true" deprecation="true" optimize="false" failοnerrοr="true" encoding="utf-8">
<classpath refid="classpath.compile" />
</javac>
</target>
<!-- 打成jar包 -->
<target name="jarRelease">
<jar destfile="${dist}/Mail2Jms2.jar" basedir="${build}/classes" includes="com/megaeyes/**" />
</target>
<!-- 拷贝配置资源给本机测试用 -->
<target name="config4debug">
<copy file="${config}/email-config.xml" tofile="${dist}/email-config.xml" />
<copy file="${config}/email2jms2.properties" tofile="${dist}/email2jms2.properties" />
</target>
<!-- release -->
<target name="jar" depends="clean,compile,config4debug,jarRelease" description="generate the war package for personal debug">
</target>
<!-- 编译打包前先清空 -->
<target name="clean" description="clean up">
<!-- Delete the ${build} and ${dist} directory trees -->
<delete dir="${build}" />
<delete dir="${dist}" />
</target>
</project>
拷贝jar包只用执行
mvn clean dependency:copy-dependencies
打包执行
ant jar
打包没有把依赖的jar包打入,这些jar包拷贝到mule2.0的lib/usr下面就行了,不要打包到自己的项目里面