一、servicemix 4.3 environment settings:
1. features:install osgi:install
features:install camel-activemq
osgi:install -s mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-dbcp/1.2.2_5
features:install camel-jpa
features:install jpa-hibernate
2. needed jars
org.springframework.transaction-2.5.6.SEC01.jar
com.springsource.org.hibernate-3.3.2.GA.jar
二、code and configuration
1. under "meta-inf " directory
(1)persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0">
<persistence-unit name="idempotentDb" transaction-type="RESOURCE_LOCAL">
<class>org.apache.camel.processor.idempotent.jpa.MessageProcessed</class>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
<property name="hibernate.hbm2ddl.auto" value="create"/>
</properties>
</persistence-unit>
</persistence>
(2)under "meta-inf/spring" directory :camel-file.xml
<?xml version="1.0"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:camel="http://camel.apache.org/schema/spring"
xmlns:osgi="http://www.springframework.org/schema/osgi"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util.xsd
http://www.springframework.org/schema/osgi
http://www.springframework.org/schema/osgi/spring-osgi.xsd
http://www.springframework.org/schema/osgi-compendium
http://www.springframework.org/schema/osgi-compendium/spring-osgi-compendium.xsd
http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd
http://www.springframework.org/schema/osgi
http://www.springframework.org/schema/osgi/spring-osgi.xsd">
<bean id="jpaStore" class="org.apache.camel.processor.idempotent.jpa.JpaMessageIdRepository">
<constructor-arg index="0" ref="jpaTemplate"/>
<constructor-arg index="1" value="FileConsumer"/>
</bean>
<bean id="jpaTemplate" class="org.springframework.orm.jpa.JpaTemplate">
<property name="entityManagerFactory" ref="entityManagerFactory"/>
</bean>
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="persistenceUnitName" value="idempotentDb"/>
<property name="jpaVendorAdapter" ref="jpaAdapter"/>
<property name="dataSource" ref="dataSource" />
</bean>
<bean id="jpaAdapter"
class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="databasePlatform" value="org.hibernate.dialect.MySQLDialect" />
</bean>
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/platform_v7_log?autoReconnect=true" />
<property name="username" value="root" />
<property name="password" value="" />
</bean>
<camelContext id="camel-A" xmlns="http://camel.apache.org/schema/spring">
<route>
<from uri="file://boxin?idempotent=true&idempotentRepository=#jpaStore"/>
<to uri="file://boxout"/>
</route>
</camelContext>
</beans>
2. pom.xml
<!--
- The ServiceMix file processor Maven build xml
-
- Copyright (C) 2000-2010 Powere2e,Inc (http://www.powere2e.com).
- All Rights Reserved.
-
- @author Peter Shen,Larry Xu
- @version $Id: pom.xml 112 2010-12-30 07:41:56Z peter $
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<repositories>
<repository>
<id>Powere2e</id>
<url> http://maven.powere2e.com/maven/</url>
</repository>
</repositories>
<groupId>com.powere2e.platform.v7</groupId>
<artifactId>CarrefourPO-JpaIdempotent2</artifactId>
<packaging>bundle</packaging>
<version>7.0.1</version>
<name>Carrefour-JpaIdempotent2</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.servicemix</groupId>
<artifactId>servicemix-bean</artifactId>
<version>2009.01</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>com.powere2e.platform.v7</groupId>
<artifactId>eagle</artifactId>
<version>1.0.9</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.0.8</version>
</dependency>
<dependency>
<groupId>com.powere2e.platform</groupId>
<artifactId>commons</artifactId>
<version>7.0.1</version>
</dependency>
<dependency>
<groupId>com.powere2e.platform</groupId>
<artifactId>messaging</artifactId>
<version>7.0.1</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-jpa</artifactId>
<version>1.5.0</version>
<scope>system</scope>
<systemPath>D:/Java/platform_v7_lib/camel-jpa-1.5.0.jar</systemPath>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>spring-jpa</artifactId>
<version>2.5.0</version>
<scope>system</scope>
<systemPath>D:/Java/platform_v7_lib/spring-jpa.jar</systemPath>
</dependency>
<!--
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
<version>2.5.0</version>
<scope>system</scope>
<systemPath>D:/Java/platform_v7_lib/camel-core-2.5.0.jar</systemPath>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
<version>1.5.0</version>
<scope>system</scope>
<systemPath>D:/Java/platform_v7_lib/camel-core-1.5.0.jar</systemPath>
</dependency>
<dependency>
<groupId>com.powere2e.platform.v7</groupId>
<artifactId>publishV7CommonService</artifactId>
<version>1.0.0</version>
<scope>system</scope>
<systemPath>D:/Java/platform_v7_lib/V7Common_messaging-log_1.0.0.jar</systemPath>
</dependency>
-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>org.springframework.orm</artifactId>
<version>2.5.6.SEC02</version>
<scope>system</scope>
<systemPath>D:/Java/platform_v7_lib/org.springframework.transaction-2.5.6.jar</systemPath>
</dependency>
<dependency>
<groupId>org.jboss</groupId>
<artifactId>ejb3-persistence</artifactId>
<version>3.0.0</version>
<scope>system</scope>
<systemPath>D:/Java/platform_v7_lib/ejb3-persistence.jar</systemPath>
</dependency>
<!-- let's use Java 5
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-http</artifactId>
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-jetty</artifactId>
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-ftp</artifactId>
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>org.springframework.orm</artifactId>
<version>2.5.6.SEC02</version>
</dependency>
-->
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-pool</artifactId>
<version>5.3.2</version>
</dependency>
<!-- -->
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-jms</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-camel</artifactId>
<version>5.4.1</version>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-core</artifactId>
<version>5.4.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<!-- configure the bundle plugin with some additional imports -->
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.0.0</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>
fileprocessor_portable_CarrefourPO
</Bundle-SymbolicName>
<Bundle-Activator>
com.powere2e.platform.v7.CarrefourPO.Activator
</Bundle-Activator>
<Import-Package>
com.powere2e.platform.messaging.exception,
com.powere2e.platform.messaging.transform,
com.powere2e.platform.messaging.util,
com.powere2e.platform.v7.commons.dao,
com.powere2e.platform.v7.commons.log,
com.powere2e.platform.v7.commons.util,
com.powere2e.platform.v7.commons.model,
com.powere2e.platform.v7.CarrefourPO,
<!-- -->
org.apache.commons.logging,
com.mysql.jdbc,
de.mendelson.eagle.transform.util,
de.mendelson.eagle.converter,
de.mendelson.eagle.converter.edixml,
<!-- -->
org.apache.servicemix.file,
org.apache.servicemix.jms,
org.apache.servicemix.bean,
<!-- -->
javax.jms;version="[1.1,2)",
org.apache.activemq;version="[5.3,6)",
org.apache.activemq.broker;version="[5.3,6)",
org.apache.activemq.camel.component;version="[5.3,6)",
org.apache.activemq.pool;version="[5.3,6)",
org.apache.activemq.xbean;version="[5.3,6)",
<!-- -->
org.apache.camel.component.jms.*;version="[2.0,2.6)",
org.apache.camel;version="[2.4,2.5)",
org.apache.camel.builder;version="[2.4,2.5)",
org.apache.camel.processor.interceptor,
org.apache.camel.builder.xml,
org.apache.camel.component.file,
org.apache.camel.component.jms;version="[2.4,2.5)",
org.apache.camel.impl;version="[2.4,2.5)",
org.apache.camel.model;version="[2.4,2.5)",
org.apache.camel.osgi,
org.apache.camel.spring;version="2.4",
org.apache.camel.processor.idempotent,
org.apache.camel.processor.idempotent.jpa,
<!--
org.springframework.transaction,
org.springframework.transaction.support,
org.springframework.orm;version="[2.5.6.SEC02,2.5.6.SEC02]",
org.hibernate.ejb,
org.springframework.transaction.support,
-->
org.springframework.orm.jpa.vendor,
org.springframework.orm.jpa,
org.springframework.orm,
org.springframework.instrument.classloading,
org.apache.openjpa.persistence,
org.hibernate.hql.ast,
<!-- -->
org.apache.openjpa.jdbc.kernel,
org.apache.commons.dbcp,
<!-- -->
org.apache.servicemix.common.osgi,*
</Import-Package>
<Export-Package>
com.powere2e.platform.v7.CarrefourPO
</Export-Package>
<classpath>
<library>osgi:org.apache.camel.camel-jms</library>
</classpath>
</instructions>
</configuration>
</plugin>
<!-- let's use Java 5 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<ant antfile="${basedir}/build.xml">
<target name="deploy" />
</ant>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>