| <div class="wiki-content maincontent"><p>ActiveMQ provides a Maven2 plugin to easily startup a JMS broker. It is useful to quickly boot up a message broker in your Maven2 project for debugging or for doing integration tests.</p> |
| |
| <h3> How to Use</h3> |
| |
| <structured-macro ac:macro-id="dddd5c9b-0b05-4664-a0e1-2f85cf8e904b" ac:name="info" ac:schema-version="1"><parameter ac:name="title">Be Careful</parameter><rich-text-body> |
| <p>The maven plugins in ActiveMQ have been renamed in version 5.8.0+ to better follow the Maven plugin naming conventions. The ActiveMQ Broker plugin has changed from 'maven-activemq-plugin' to 'activemq-maven-plugin'.</p></rich-text-body></structured-macro> |
| |
| <blockquote><p>Replace the 5.7.0 version string with the version of your choosing, eg: 5.6.0, 5.8-SNAPSHOT</p></blockquote> |
| |
| <p>In your Maven2 project, or using a minimal pom.xml like the following:</p> |
| <structured-macro ac:macro-id="74be901c-fa78-4225-8536-0118f832f63a" ac:name="code" ac:schema-version="1"><plain-text-body><?xml version="1.0" encoding="UTF-8"?> |
| <project> |
| <modelVersion>4.0.0</modelVersion> |
| <groupId>com.acme</groupId> |
| <artifactId>run-amq</artifactId> |
| <version>1.0-SNAPSHOT</version> |
| </project></plain-text-body></structured-macro> |
| <p>just type:</p> |
| <structured-macro ac:macro-id="be7378b3-e88a-478f-8eb0-cc12f92dc3a7" ac:name="code" ac:schema-version="1"><plain-text-body> |
| mvn org.apache.activemq.tooling:maven-activemq-plugin:5.1:run |
| </plain-text-body></structured-macro> |
| <p>This will download the 5.7.0 version of the plugin, and spin up a broker using a simple configuration url of the form <code>broker:(tcp://localhost:61616)?useJmx=false&persistent=false</code>. The necessary ActiveMQ jars will automatically be downloaded by Maven.</p> |
| |
| <p>To configure log4j, provide the <code>-Dlog4j.configuration=<a shape="rect" class="external-link" href="file:///" rel="nofollow">file:///</a><full path to log4j.properties></code> system property on the mvn command line.</p> |
| |
| <p>If you require a more advanced configuration with spring support, the jetty webconsole or with embedded camel you can add the plugin in your pom.xml and provide the required optional dependencies. For the default <code>conf/activemq.xml</code>, the following dependencies are required :</p> |
| <structured-macro ac:macro-id="a8cfc138-e1f3-4868-b986-7dafb111f494" ac:name="code" ac:schema-version="1"><plain-text-body> |
| <build> |
| <plugins> |
| <plugin> |
| <groupId>org.apache.activemq.tooling</groupId> |
| <artifactId>maven-activemq-plugin</artifactId> |
| <version>5.7.0</version> |
| <configuration> |
| <configUri>xbean:file:../conf/activemq.xml</configUri> |
| <fork>false</fork> |
| <systemProperties> |
| <property> |
| <name>javax.net.ssl.keyStorePassword</name> |
| <value>password</value> |
| </property> |
| <property> |
| <name>org.apache.activemq.default.directory.prefix</name> |
| <value>./target/</value> |
| </property> |
| </systemProperties> |
| </configuration> |
| <dependencies> |
| <dependency> |
| <groupId>org.springframework</groupId> |
| <artifactId>spring</artifactId> |
| <version>2.5.5</version> |
| </dependency> |
| <dependency> |
| <groupId>org.mortbay.jetty</groupId> |
| <artifactId>jetty-xbean</artifactId> |
| <version>6.1.11</version> |
| </dependency> |
| <dependency> |
| <groupId>org.apache.camel</groupId> |
| <artifactId>camel-activemq</artifactId> |
| <version>1.1.0</version> |
| </dependency> |
| </dependencies> |
| </plugin> |
| </plugins> |
| </build> |
| </plain-text-body></structured-macro> |
| <p> and run it using:</p> |
| <structured-macro ac:macro-id="8b564575-8cc6-4315-85c6-d53147b3df62" ac:name="code" ac:schema-version="1"><plain-text-body> |
| mvn activemq:run |
| </plain-text-body></structured-macro> |
| |
| |
| <h3> Configuration Options</h3> |
| |
| <table><tbody><tr><th colspan="1" rowspan="1"><p> Name </p></th><th colspan="1" rowspan="1"><p> Default </p></th><th colspan="1" rowspan="1"><p> Description </p></th></tr><tr><td colspan="1" rowspan="1"><p> configUri </p></td><td colspan="1" rowspan="1"><p> broker:(tcp://localhost:61616)?useJmx=false&persistent=false </p></td><td colspan="1" rowspan="1"><p> The broker configuration URI that will be use to startup the broker. For more information, refer <link ac:tooltip="How do I embed a Broker inside a Connection"><page ri:content-title="How do I embed a Broker inside a Connection"></page><link-body>here</link-body></link><br clear="none" class="atl-forced-newline"> </p></td></tr><tr><td colspan="1" rowspan="1"><p> fork </p></td><td colspan="1" rowspan="1"><p> false </p></td><td colspan="1" rowspan="1"><p> If true, start up the broker in a separate thread, enabling maven to continue processing (Useful for integration testing).<br clear="none" class="atl-forced-newline"> </p></td></tr><tr><td colspan="1" rowspan="1"><p> systemProperties </p></td><td colspan="1" rowspan="1"><p> none </p></td><td colspan="1" rowspan="1"><p> Additional system properties that will be set.<br clear="none" class="atl-forced-newline"> </p></td></tr></tbody></table> |
| |
| <p> Note: By default, the broker plugin will set activemq.base, activemq.home, org.apache.activemq.default.directory.prefix, derby.system.home to ./target/. This means that all data folders will be created there, hence will easily be deleted by running mvn clean.</p></div> |
| |