Search Tutorials

Spring Boot + ActiveMQ Hello world Example | JavaInUse

Spring Boot + ActiveMQ Hello world Example

In this post we create a spring boot application and integrate it with ActiveMQ. In a previous ActiveMQ post had created a ActiveMQ Hello World Application using core java. But as can be seen in that post it involved a lot of boiler plate code. With Spring boot no boilerplate or configuration code is required.

Lets Begin-

Download ActiveMQ from Extract it. In the bin folder click on activemq.bat and start ActiveMQ as follows.
and goto http://localhost:8161/admin/queues.jsp, we will see no queues on this page.
We will now begin with the spring boot code-


In the Maven we only need the spring-boot-starter-activemq dependency.Maven will be as follows-
<project xmlns="" xmlns:xsi=""
	<description>Demo project for Spring Boot</description>

		<relativePath /> <!-- lookup parent from repository -->



Create the as follows. Using JMSTemplate we have added the new queue named 'javainuse'. So unlike the previous post of creating activemq connection, no boilerplate code for adding session and all is required.
package com.javainuse;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.jms.core.JmsTemplate;

public class SpringBootHelloWorldApplication {

	public static void main(String[] args) {
		ApplicationContext ctx =
				SpringBootHelloWorldApplication.class, args);
		JmsTemplate jms = ctx.getBean(JmsTemplate.class);
		jms.convertAndSend("javainuse", "test message");

Create the as follows-

This is the only code required. Now start the ActiveMQ. Start the spring boot application by running the SpringBootHelloWorldApplication as a java application. Go to http://localhost:8161 and a new queue named javainuse will be created.

Download Source Code

Download it -
Spring Boot + ActiveMQ Hello world Example

See Also

Spring Boot Hello World Application- Create simple controller and jsp view using Maven Spring Boot Hello World Application- Create simple controller and jsp view using Gradle Spring Boot Tutorial-Spring Data JPA Spring Boot + Simple Security Configuration Pagination using Spring Boot Simple Example Spring Boot + Swagger Example Hello World Example Spring Boot + Swagger- Understanding the various Swagger Annotations Spring Boot Main Menu Spring Boot Interview Questions