blob: cb24a17af6b1c08cdddb1f7576575b3fbf5d26ff [file] [log] [blame]
<div class="wiki-content maincontent"><h1>Running an ActiveMQ Broker</h1><p>Note if you want to use an <strong>embedded broker</strong> then see <link><page ri:content-title="How do I embed a Broker inside a Connection"></page></link></p><p>The <link><page ri:content-title="Download"></page><plain-text-link-body>binary distribution</plain-text-link-body></link> of ActiveMQ comes with a script called 'activemq' which allows you to run a broker. <br clear="none">For details regarding the activemq init script file review&#160; <link><page ri:content-title="Unix Shell Script"></page></link>&#160; and&#160; <link><page ri:content-title="ActiveMQ Command Line Tools Reference"></page></link></p><p>&#160;</p><p>Typing the following will run an ActiveMQ Broker using the out of the box configuration in the foreground</p><structured-macro ac:macro-id="968eaf92-8c93-4dd5-aee6-a10bda8a56d0" ac:name="code" ac:schema-version="1"><parameter ac:name="language">bash</parameter><plain-text-body>bin/activemq console
</plain-text-body></structured-macro><p>You can then use a <link><page ri:content-title="Broker Configuration URI"></page></link> to specify how to start and configure your broker using a single URI. For example</p><structured-macro ac:macro-id="eb0175b5-2f19-47a7-8386-ed2ee18f4b67" ac:name="code" ac:schema-version="1"><parameter ac:name="language">bash</parameter><plain-text-body>bin/activemq console broker:(tcp://localhost:61616,network:static:tcp://remotehost:61616)?persistent=false&amp;useJmx=true
</plain-text-body></structured-macro><p>Or you can a <link><page ri:content-title="Broker XBean URI"></page></link> to customize the Message Broker using the <link><page ri:content-title="Xml Configuration"></page></link> to suit your needs. You can run a broker with a specific XML configuration as</p><structured-macro ac:macro-id="4eb92bf8-f24b-4ca0-bb5b-00dad43cb85e" ac:name="code" ac:schema-version="1"><parameter ac:name="language">bash</parameter><plain-text-body>bin/activemq console xbean:foo.xml
</plain-text-body></structured-macro><p>Or you can use a <link><page ri:content-title="Broker Properties URI"></page></link> to customize the Message Broker using a properties file; which avoids the dependency on Spring, xbean-spring and XML.</p><structured-macro ac:macro-id="a215deb1-788d-4ef3-bd23-95a9bcbdc608" ac:name="code" ac:schema-version="1"><parameter ac:name="language">bash</parameter><plain-text-body>bin/activemq console properties:foo.properties</plain-text-body></structured-macro><h3>Monitoring the broker</h3><p><structured-macro ac:macro-id="00dff49d-cda2-4f51-900b-617d2dc37964" ac:name="include" ac:schema-version="1"><parameter ac:name=""><link><page ri:content-title="Monitoring ActiveMQ"></page></link></parameter></structured-macro></p><h3>Running the broker inside a Servlet Engine</h3><p>See the source code (or WAR) of the <link><page ri:content-title="Web Console"></page></link> for an example of how to run the broker inside a web application using Spring.</p><h3>Running the broker inside your J2EE Application Server</h3><p>Whether its Apache Geronmio, JBoss, WebLogic or some other J2EE container you should be able to just reconfigure and then deploy the activemq-*.rar which is included in the binary distribution as a deployment unit in your app server. By default the rar is not configured to start an embedded broker. But by setting the brokerXmlConfig on the resource adapter configuration, the resource adapter will start an embedded broker.</p><p>For more details see <link><page ri:content-title="J2EE"></page></link></p><h3>Running the broker from the source code</h3><p>From the latest <link><page ri:content-title="Source"></page><plain-text-link-body>checkout</plain-text-link-body></link> of the code you can run a broker using the <link><page ri:content-title="ActiveMQ Performance Module Users Manual"></page><plain-text-link-body>ActiveMQ Performance Plugin</plain-text-link-body></link></p><h3>Running the broker from maven</h3><p>You can download and install the ActiveMQ Startup Maven Plugin via the following command if you are in a directory with a pom.xml. More detailed usage <link><page ri:content-title="Maven2 ActiveMQ Broker Plugin"></page><plain-text-link-body>here</plain-text-link-body></link></p><structured-macro ac:macro-id="35b3b149-9832-422f-a477-f9b81c5deb59" ac:name="code" ac:schema-version="1"><plain-text-body>mvn org.apache.activemq.tooling:maven-activemq-plugin:5.0-SNAPSHOT:run
</plain-text-body></structured-macro><p>You can also include it the pom and run it using:</p><structured-macro ac:macro-id="94a43058-7ff3-49a5-a104-7c8a83bc9f36" ac:name="code" ac:schema-version="1"><plain-text-body>mvn activemq:run
</plain-text-body></structured-macro><h2>Handling JMS brokers going down</h2><p>A common requirement is that if the JMS broker goes down you want to automatically detect the failure and try to reconnect under the covers so that your application does not have to worry about reconnection.</p><p>There is detailed documentation on this in <link><page ri:content-title="Configuring Version 5 Transports"></page></link>; briefly...</p><p>Just change your connection URI i to</p><structured-macro ac:macro-id="808df444-bb4e-43fd-9bf0-915d8ddfbe13" ac:name="code" ac:schema-version="1"><plain-text-body>failover:tcp://host:port
</plain-text-body></structured-macro><p>And the JMS client will auto-reconnect to the broker if it is shutdown and restarted later on.</p></div>