blob: 33148cd6bf3f9710a040e4ba0d7dbe73250a7702 [file] [log] [blame]
<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">&#160;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">
<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;project&gt;
&lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
&lt;groupId&gt;com.acme&lt;/groupId&gt;
&lt;artifactId&gt;run-amq&lt;/artifactId&gt;
&lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
&lt;/project&gt;</pre>
</div></div>
<p>just type:</p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">
mvn org.apache.activemq.tooling:maven-activemq-plugin:5.1:run
</pre>
</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&amp;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>&lt;full path to log4j.properties&gt;</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">
<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">
&lt;build&gt;
&lt;plugins&gt;
&lt;plugin&gt;
&lt;groupId&gt;org.apache.activemq.tooling&lt;/groupId&gt;
&lt;artifactId&gt;maven-activemq-plugin&lt;/artifactId&gt;
&lt;version&gt;5.7.0&lt;/version&gt;
&lt;configuration&gt;
&lt;configUri&gt;xbean:file:../conf/activemq.xml&lt;/configUri&gt;
&lt;fork&gt;false&lt;/fork&gt;
&lt;systemProperties&gt;
&lt;property&gt;
&lt;name&gt;javax.net.ssl.keyStorePassword&lt;/name&gt;
&lt;value&gt;password&lt;/value&gt;
&lt;/property&gt;
&lt;property&gt;
&lt;name&gt;org.apache.activemq.default.directory.prefix&lt;/name&gt;
&lt;value&gt;./target/&lt;/value&gt;
&lt;/property&gt;
&lt;/systemProperties&gt;
&lt;/configuration&gt;
&lt;dependencies&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.springframework&lt;/groupId&gt;
&lt;artifactId&gt;spring&lt;/artifactId&gt;
&lt;version&gt;2.5.5&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.mortbay.jetty&lt;/groupId&gt;
&lt;artifactId&gt;jetty-xbean&lt;/artifactId&gt;
&lt;version&gt;6.1.11&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
&lt;groupId&gt;org.apache.camel&lt;/groupId&gt;
&lt;artifactId&gt;camel-activemq&lt;/artifactId&gt;
&lt;version&gt;1.1.0&lt;/version&gt;
&lt;/dependency&gt;
&lt;/dependencies&gt;
&lt;/plugin&gt;
&lt;/plugins&gt;
&lt;/build&gt;
</pre>
</div></div>
<p>&#160;and run it using:</p>
<div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">
mvn activemq:run
</pre>
</div></div>
<h3 id="Maven2ActiveMQBrokerPlugin-ConfigurationOptions">&#160;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&amp;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.html">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>&#160;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>