Note if you want to use an embedded broker then see How do I embed a Broker inside a Connection
This page describes how to run a broker using 4.x or later of ActiveMQ. For earlier versions of ActiveMQ see Running a 3.x Broker
The binary distribution of ActiveMQ comes with a script called 'activemq' which allows you to run a broker. Typing the following will run an ActiveMQ Broker using the out of the box configuration
There are a number of different command line options to be able to run a broker. To see them type
For more details regarding the activemq script file and other script files refer to ActiveMQ Command Line Tools Reference
You can then use a Broker Configuration URI to specify how to start and configure your broker using a single URI. For example
Or you can use a Broker Properties URI to customize the Message Broker using a properties file; which avoids the dependency on Spring, xbean-spring and XML.
See the Unix Service for details.
See the Java Service Wrapper Page for details.
Or you can use the JMX support to view the running state of ActiveMQ.
See the source code (or WAR) of the Web Console for an example of how to run the broker inside a web application using Spring.
Whether its Apache Geronmio, JBoss 4, WebLogic 9 or some other J2EE 1.4 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.
For more details see J2EE
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 here
You can also include it the pom and run it using:
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.
There is detailed documentation on this in Configuring Transports; briefly...
Just change your connection URI in 4.x to
And the JMS client will auto-reconnect to the broker if it is shutdown and restarted later on.