Use the Maven archetype, camel-archetype-java
, to generate a
sample Java application which you can then use as a starting point for your
application.
To generate the new project, perform the following steps:
Open a new command window and change to the directory where you want to store the new Maven project.
Enter the following command to generate the new Maven project:
mvn archetype:create -DremoteRepositories=https://repository.apache.org/content/groups/public -DarchetypeGroupId=org.apache.camel.archetypes -DarchetypeArtifactId=camel-archetype-java -DarchetypeVersion=2.8.0-fuse-00-08 -DgroupId=tutorial -DartifactId=tx-jms-router
This command generates a basic router application under the
tx-jms-router
directory. You will customize this basic application to demonstrate transactions in .Fuse Mediation RouterNote Maven accesses the Internet to download JARs and stores them in its local repository.
Customize the project POM file,
tx-jms-router/pom.xml
, by adding some new project dependencies. First of all, define some properties for the dependency versions. Using your favorite text editor, open the POM file and add aspring-version
property and anactivemq-version
property as follows:<project ...> ... <properties> ... <spring-version>3.0.5.RELEASE</spring-version> <activemq-version>5.5.1-fuse-00-08</activemq-version> <xbean-version>3.7</xbean-version> </properties> ... </project>
Add dependencies on the artifacts that implement Spring transactions. Look for the
dependencies
element in the POM file and add the followingdependency
elements:<project ...> ... <dependencies> ... <!-- Spring transaction dependencies --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>${spring-version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>${spring-version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-tx</artifactId> <version>${spring-version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-aop</artifactId> <version>${spring-version}</version> </dependency> </dependencies> ... </project>
Add the JMS and ActiveMQ dependencies. Look for the
dependencies
element in the POM file and add the followingdependency
elements:<project ...> ... <dependencies> ... <!-- Persistence artifacts --> <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-jms</artifactId> <version>${camel-version}</version> </dependency> <dependency> <groupId>org.apache.activemq</groupId> <artifactId>activemq-core</artifactId> <version>${activemq-version}</version> </dependency> <!-- This is needed by the camel-jms component --> <dependency> <groupId>org.apache.xbean</groupId> <artifactId>xbean-spring</artifactId> <version>${xbean-version}</version> </dependency> </dependencies> ... </project>