Spring Boot – Embedded ActiveMQ

Last Updated on

This post demonstrates how to embed an ActiveMQ instance in Spring Boot and produce/consume messages with a simple example.

Spring Boot Application

You may still use the Spring Initialzr which is fine but we need to update the generated pom.xml to include additional dependencies.

Our @Configuration class

We have two parts here – the embedded JMS server and client-stuff sections. @EnableJMS f is just an annotation that allows us to use @JmsListener (see MessageReceiver class).

Our Main class

In this class, we send a message to the JMS queue.

Sample Output

Download the Codes



Karl San Gabriel

Karl San Gabriel

Professional Software Developer