{"id":5474,"date":"2016-05-15T07:08:49","date_gmt":"2016-05-15T12:08:49","guid":{"rendered":"http:\/\/appcrawler.com\/wordpress\/?p=5474"},"modified":"2016-05-15T07:08:49","modified_gmt":"2016-05-15T12:08:49","slug":"simple-camel-project-with-full-maven-instructions","status":"publish","type":"post","link":"http:\/\/appcrawler.com\/wordpress\/2016\/05\/15\/simple-camel-project-with-full-maven-instructions\/","title":{"rendered":"Simple camel project with full maven instructions"},"content":{"rendered":"<p>Generate maven project stub directory&#8230;<\/p>\n<pre>\r\nmvn archetype:generate -DgroupId=com.yourcompany.it.arch.poc.esb -DartifactId=esbpoc -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false\r\n<\/pre>\n<p>&#8230;then create the single class in our POC&#8230;<\/p>\n<pre>\r\npackage com.yourcompany.it.arch.poc.esb;\r\n\r\nimport javax.jms.ConnectionFactory;\r\n\r\nimport org.apache.activemq.*;\r\nimport org.apache.camel.*;\r\nimport org.apache.camel.builder.*;\r\nimport org.apache.camel.component.jms.*;\r\nimport org.apache.camel.impl.*;\r\n\r\npublic final class App {\r\n public static void main(String args[]) throws Exception {\r\n   CamelContext context = new DefaultCamelContext();\r\n   ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(\"vm:\/\/localhost?broker.persistent=false\");\r\n   context.addComponent(\"test-jms\", JmsComponent.jmsComponentAutoAcknowledge(connectionFactory));\r\n   context.addRoutes(new RouteBuilder() {\r\n     public void configure() {\r\n       from(\"test-jms:queue:test.queue\").to(\"file:\/\/test\");\r\n     }\r\n   });\r\n   ProducerTemplate template = context.createProducerTemplate();\r\n   context.start();\r\n   for (int i = 0; i < 10; i++) {\r\n     template.sendBody(\"test-jms:queue:test.queue\", \"Test Message: \" + i);\r\n   }\r\n   Thread.sleep(1000);\r\n   context.stop();\r\n  }\r\n}\r\n<\/pre>\n<p>...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...<\/p>\n<pre>\r\n<project xmlns=\"http:\/\/maven.apache.org\/POM\/4.0.0\" xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"\r\n  xsi:schemaLocation=\"http:\/\/maven.apache.org\/POM\/4.0.0 http:\/\/maven.apache.org\/maven-v4_0_0.xsd\">\r\n  <modelVersion>4.0.0<\/modelVersion>\r\n  <groupId>com.yourcompany.it.arch.poc.esb<\/groupId>\r\n  <artifactId>esbpoc<\/artifactId>\r\n  <packaging>jar<\/packaging>\r\n  <version>1.0-SNAPSHOT<\/version>\r\n  <name>esbpoc<\/name>\r\n  <url>http:\/\/maven.apache.org<\/url>\r\n  <dependencies>\r\n    <dependency>\r\n      <groupId>junit<\/groupId>\r\n      <artifactId>junit<\/artifactId>\r\n      <version>3.8.1<\/version>\r\n      <scope>test<\/scope>\r\n    <\/dependency>\r\n    <dependency>\r\n      <groupId>org.apache.camel<\/groupId>\r\n      <artifactId>camel-spring<\/artifactId>\r\n      <version>2.15.1<\/version>\r\n    <\/dependency>\r\n    <dependency>\r\n      <groupId>org.apache.camel<\/groupId>\r\n      <artifactId>camel-spring-javaconfig<\/artifactId>\r\n      <version>2.15.1<\/version>\r\n    <\/dependency>\r\n    <dependency>\r\n      <groupId>org.apache.camel<\/groupId>\r\n      <artifactId>camel-jms<\/artifactId>\r\n      <version>2.15.1<\/version>\r\n    <\/dependency>\r\n    <dependency>\r\n      <groupId>org.apache.activemq<\/groupId>\r\n      <artifactId>activemq-spring<\/artifactId>\r\n      <version>5.12.1<\/version>\r\n    <\/dependency>\r\n  <\/dependencies>\r\n\r\n  <build>\r\n    <pluginManagement>\r\n      <plugins>\r\n        <plugin>\r\n          <groupId>org.apache.maven.plugins<\/groupId>\r\n          <artifactId>maven-assembly-plugin<\/artifactId>\r\n          <configuration>\r\n            <archive>\r\n              <manifest><mainClass>com.yourcompany.it.arch.poc.esb.App<\/mainClass><\/manifest>\r\n            <\/archive>\r\n            <descriptorRefs>\r\n              <descriptorRef>jar-with-dependencies<\/descriptorRef>\r\n            <\/descriptorRefs>\r\n          <\/configuration>\r\n        <\/plugin>\r\n      <\/plugins>\r\n    <\/pluginManagement>\r\n  <\/build>\r\n<\/project>\r\n<\/pre>\n<p>...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...<\/p>\n<pre>\r\nmvn clean compile assembly:single\r\n<\/pre>\n<p>...and finally, we run our class...<\/p>\n<pre>\r\njava -cp target\\esbpoc-1.0-SNAPSHOT-jar-with-dependencies.jar com.yourcompany.it.arch.esb.App\r\n<\/pre>\n<p>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.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Generate maven project stub directory&#8230; mvn archetype:generate -DgroupId=com.yourcompany.it.arch.poc.esb -DartifactId=esbpoc -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false &#8230;then create the single class in our POC&#8230; 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&hellip;<\/p>\n<p class=\"more-link-p\"><a class=\"more-link\" href=\"http:\/\/appcrawler.com\/wordpress\/2016\/05\/15\/simple-camel-project-with-full-maven-instructions\/\">Read more &rarr;<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"footnotes":""},"categories":[70,69,25],"tags":[],"_links":{"self":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/5474"}],"collection":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/comments?post=5474"}],"version-history":[{"count":3,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/5474\/revisions"}],"predecessor-version":[{"id":5478,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/5474\/revisions\/5478"}],"wp:attachment":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/media?parent=5474"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/categories?post=5474"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/tags?post=5474"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}