| <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 id="Maven2ActiveMQBrokerPlugin-HowtoUse"> How to Use</h3> |
| |
| <div class="confluence-information-macro confluence-information-macro-information"><p class="title">Be Careful</p><span class="aui-icon aui-icon-small aui-iconfont-info confluence-information-macro-icon"></span><div class="confluence-information-macro-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></div></div> |
| |
| <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> |
| <div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> |
| <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[<?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>]]></script> |
| </div></div> |
| <p>just type:</p> |
| <div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> |
| <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ |
| mvn org.apache.activemq.tooling:maven-activemq-plugin:5.1:run |
| ]]></script> |
| </div></div> |
| <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> |
| <div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> |
| <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ |
| <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> |
| ]]></script> |
| </div></div> |
| <p> and run it using:</p> |
| <div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> |
| <script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[ |
| mvn activemq:run |
| ]]></script> |
| </div></div> |
| |
| |
| <h3 id="Maven2ActiveMQBrokerPlugin-ConfigurationOptions"> Configuration Options</h3> |
| |
| <div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p> Name </p></th><th colspan="1" rowspan="1" class="confluenceTh"><p> Default </p></th><th colspan="1" rowspan="1" class="confluenceTh"><p> Description </p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> configUri </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> broker:(tcp://localhost:61616)?useJmx=false&persistent=false </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> The broker configuration URI that will be use to startup the broker. For more information, refer <a shape="rect" href="how-do-i-embed-a-broker-inside-a-connection.xml">here</a><br clear="none" class="atl-forced-newline"> </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p> fork </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> false </p></td><td colspan="1" rowspan="1" class="confluenceTd"><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" class="confluenceTd"><p> systemProperties </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> none </p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> Additional system properties that will be set.<br clear="none" class="atl-forced-newline"> </p></td></tr></tbody></table></div> |
| |
| <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> |
| |