Generate maven project stub directory…
mvn archetype:generate -DgroupId=com.yourcompany.it.arch.poc.esb -DartifactId=esbpoc -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
…then create the single class in our POC…
package com.yourcompany.it.arch.poc.esb; import javax.jms.ConnectionFactory; import org.apache.activemq.*; import org.apache.camel.*; import org.apache.camel.builder.*; import org.apache.camel.component.jms.*; import org.apache.camel.impl.*; public final class App { public static void main(String args[]) throws Exception { CamelContext context = new DefaultCamelContext(); ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false"); context.addComponent("test-jms", JmsComponent.jmsComponentAutoAcknowledge(connectionFactory)); context.addRoutes(new RouteBuilder() { public void configure() { from("test-jms:queue:test.queue").to("file://test"); } }); ProducerTemplate template = context.createProducerTemplate(); context.start(); for (int i = 0; i < 10; i++) { template.sendBody("test-jms:queue:test.queue", "Test Message: " + i); } Thread.sleep(1000); context.stop(); } }
...then edit the pom.xml in your project directory to look like what is below. This is the directory in which you ran the mvn command initially listed above...
4.0.0 com.yourcompany.it.arch.poc.esb esbpoc jar 1.0-SNAPSHOT esbpoc http://maven.apache.org junit junit 3.8.1 test org.apache.camel camel-spring 2.15.1 org.apache.camel camel-spring-javaconfig 2.15.1 org.apache.camel camel-jms 2.15.1 org.apache.activemq activemq-spring 5.12.1 org.apache.maven.plugins maven-assembly-plugin com.yourcompany.it.arch.poc.esb.App jar-with-dependencies
...then the moment has arrived at which we compile our project, running what is below, again, in the directory in which our pom.xml file lives...
mvn clean compile assembly:single
...and finally, we run our class...
java -cp target\esbpoc-1.0-SNAPSHOT-jar-with-dependencies.jar com.yourcompany.it.arch.esb.App
If you have done everything listed above, you should see several files in the test directory under your base project (where pom.xml lives). These were generated message files running the code above.