Available on GitHub

Demo available on GitHub


This is just a very small, very simple template project for sending messages to JMS queues.

In my current role we have a lot of different components and systems glued together by ActiveMQ and Camel. When developingintegration testing in this environment – it is often useful to create ad-hoc messages and send them to queues directly. This is usually the case when you need to test a subset of a larger system.

I usually knock up a test app to do this, often replicating this functionality time and time again. So I thought it might be useful to pop this into a simple template project that can be easily reused. It also made sense to ‘mavenise’ and ‘springify’ to make it more easily extensible if you need to plug in other components and features in tests.

Just to reiterate – this is just a starting point for developer style, ad hoc testing to support the development process.

Running the Demo

  1. Prerequisites
    1. Running instance of ActiveMQ (local/remote)
    2. Maven and JDK installed
  2. Configuring
    1. Edit application.properties to point to your ActiveMQ instance – specifying broker url and queue name
    2. Edit ‘StartDemo.java’ to provide the ObjectMessage the endpoint is expecting
    3. Type ‘maven exec:java’ to run the StartDemo class




Looking at the Code

All the Spring configuration is set up in the main application-context.xml


The ObjectMessages are created in the main StartDemo.java class


Communication with the server is abstracted away into a Dispatcher object.


And that’s about it really!


As stated at the start – this is just a throwaway project I use as a starting point when I need to write something to send messages to an ActiveMQ Queue/

It’s a compromise between something super simple (like a simple class), and something that lends itself easily to being extended. What can often start off as a simple test can grow into something more complex – and as we have maven and spring all configured at the start – it’s then very easy to add in extra dependencies if you find you need them.

(Visited 196 times, 1 visits today)
Spring ActiveMQ Producer Client Template
Tagged on: