Since version 5.12.0, Apache ActiveMQ comes with the new tool that can be used to produce and consume messages from the broker.



Before running the examples you should try running a JMS broker on your machine. Follow the Installation instructions to use a binary distribution of ActiveMQ. To run the broker in a command shell, type:



This starts up ActiveMQ.


From the command line you can run


If you have activemq-all jar available you can achieve the same with

If you run inside Karaf, you can run the commands as



For all options on the commands, run them with --help parameter. The up to date, options for producer and consumer can be found in the source.


Here are a couple of examples of more advanced features.

To send a text message with custom text use

To send byte message of custom length use

To send a text message with content obtained from an url

To consume in transaction use

To use client acknowledgment use

To use durable topic subscribers use

Old examples

In older versions of ActiveMQ, the corresponding examples were located in examples/ or examples/openwire/swissarmy/ directories, where you can do the similar tasks with an ant script.

Other examples

In examples/ directory (depending on the version) you can find more examples of using the broker with variety of protocols (mqtt, amqp, ...) and clients (Java, Ruby, JavaScript, ...), so it's the good place to start learning. Also, examples/conf/ directory contains a lot of different configuration examples that you can use as a starting point for your deployment.

See Also

© 2004-2011 The Apache Software Foundation.
Apache ActiveMQ, ActiveMQ, Apache, the Apache feather logo, and the Apache ActiveMQ project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.
Graphic Design By Hiram