Spring Boot + ActiveMQ Hello world Example
Lets Begin-
Download ActiveMQ from http://activemq.apache.org/download.html. Extract it. In the bin folder click on activemq.bat and start ActiveMQ as follows.


In the Maven we only need the spring-boot-starter-activemq dependency.Maven will be as follows-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.test</groupId> <artifactId>SpringBoot-JMS-HelloWorld</artifactId> <version>0.0.1-SNAPSHOT</version> <name>SpringBootHelloWorld</name> <description>Demo project for Spring Boot</description> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.4.1.RELEASE</version> <relativePath /> <!-- lookup parent from repository --> </parent> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <java.version>1.8</java.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-activemq</artifactId> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> </project>
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;
@SpringBootApplication
public class SpringBootHelloWorldApplication {
public static void main(String[] args) {
ApplicationContext ctx = SpringApplication.run(
SpringBootHelloWorldApplication.class, args);
JmsTemplate jms = ctx.getBean(JmsTemplate.class);
jms.convertAndSend("javainuse", "test message");
}
}
