Home » Enterprise Java » spring » Spring ActiveMQ Example

About Bhagvan Kommadi

Bhagvan Kommadi is the Founder of Architect Corner & has around 20 years’ experience in the industry, ranging from large scale enterprise development to helping incubate software product start-ups. He has done Masters in Industrial Systems Engineering at Georgia Institute of Technology (1997) and Bachelors in Aerospace Engineering from Indian Institute of Technology, Madras (1993). He is member of IFX forum,Oracle JCP and participant in Java Community Process. He founded Quantica Computacao, the first quantum computing startup in India. Markets and Markets have positioned Quantica Computacao in ‘Emerging Companies’ section of Quantum Computing quadrants. Bhagvan has engineered and developed simulators and tools in the area of quantum technology using IBM Q, Microsoft Q# and Google QScript. He has reviewed the Manning book titled : "Machine Learning with TensorFlow”. He is also the author of Packt Publishing book - "Hands-On Data Structures and Algorithms with Go".He is member of IFX forum,Oracle JCP and participant in Java Community Process. He is member of the MIT Technology Review Global Panel.

Spring ActiveMQ Example

1. Introduction

This is an in-depth article related to the Spring ActiveMQ. Spring Boot framework has features to build applications. Spring Boot has features related to building rest services and unit testing the application. ActiveMQ is configured using the classpath environment variable. Spring ActiveMQ uses embedded broker and ActiveMQ custom configurations in the application. properties.

2. Spring ActiveMQ

2.1 Prerequisites

Java 8 or 9 is required on the Linux, windows, or Mac operating system. Maven 3.6.1 is required for building the spring application.

2.2 Download

You can download Java 8 can be downloaded from the Oracle web site . Apache Maven 3.6.1 can be downloaded from Apache site. Spring framework’s latest releases are available from the spring website. Active MQ can be downloaded from the ActiveMQ site.

2.3 Setup

You can set the environment variables for JAVA_HOME and PATH. They can be set as shown below:

Setup For Java
JAVA_HOME="/desktop/jdk1.8.0_73"
export JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH
export PATH

The environment variables for maven are set as below:

Environment Setup for Maven
JAVA_HOME=”/jboss/jdk1.8.0_73″
export M2_HOME=/users/bhagvan.kommadi/Desktop/apache-maven-3.6.1
export M2=$M2_HOME/bin
export PATH=$M2:$PATH

2.4 Building the application

2.4.1 Spring

You can start building Spring applications using the Spring Boot framework. Spring Boot has a minimal configuration of Spring. Spring Boot has features related to security, tracing, application health management, and runtime support for web servers. Spring configuration is done through maven pom.xml. The XML configuration is shown below:

Spring Configuration
<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
  
    <groupId>org.springframework</groupId>
    <artifactId>spring-helloworld</artifactId>
    <version>0.1.0</version>
  
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.4.RELEASE</version>
    </parent>
  
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>
  
    <properties>
        <java.version>1.8</java.version>
    </properties>
  
  
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
  
</project>

You can create a HelloWorldController class as the web controller. The class is annotated using @RestController. Rest Controller is used to handle requests in Spring Model View Controller framework. Annotation @RequestMapping is used to annotate the index() method. The code for the HelloWorldController class is shown below:

HelloWorld Controller
package helloworld;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestMapping;
   
@RestController
public class HelloWorldController {
       
    @RequestMapping("/")
    public String index() {
        return "Hello World\n";
    }
       
}

HelloWorldApp is created as the Spring Boot web application. When the application starts, beans, ​and settings are wired up dynamically. They are applied to the application context. The code for HelloWorldApp class is shown below:

HelloWorld App
package helloworld;
import java.util.Arrays;
   
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
   
@SpringBootApplication
public class HelloWorldApp {
       
    public static void main(String[] args) {
        ApplicationContext ctx = SpringApplication.run(HelloWorldApp.class, args);
           
        System.out.println("Inspecting the beans");
           
        String[] beans = ctx.getBeanDefinitionNames();
        Arrays.sort(beans);
        for (String name : beans) {
            System.out.println("Bean Name" +name);
        }
    }
   
}

Maven is used for building the application. The command below builds the application.

Maven Build Command
mvn package

The output of the executed command is shown below.

spring activemq - Maven Build
Maven Build

The jar file spring-helloworld-0.1.0.jar is created. The following command is used for executing the jar file.

Run Command
java -jar target/spring-helloworld-0.1.0.jar

The output of the executed command is shown below.

spring activemq - Spring Beans
Spring Beans

The curl command is invoked on the command line for the execution of the index method. The method returns a string “Hello World” text. @RestController aggregates the two annotations @Controller and @ResponseBody. This results in returning data. The output is shown below.

spring activemq- Curl Command
Curl Command

2.5 What is Apache ActiveMQ? 

Microservices use HTTP and Asynchronous messaging protocols for communication. Event-driven architectures are based on asynchronous messaging. Domain model changes are modeled as events and events are used to share the changes in the domain model. This helps in decoupling the microservices and the domain model. Messaging pattern is used in event-driven architecture for guaranteed delivery of messages. This is done using various software packages like ActiveMQ, RabbitMQ, Apache Kafka, and others.

Apache ActiveMQ is built in Java. It has support for JMS, REST, and WebSocket interfaces. The protocols such as AMQP, MQTT, OpenWire, and STOMP are supported in various languages.

2.6 Why we use it? 

ActiveMQ messaging service is based on the JMS messaging standard. This standard is used in Java applications. Messages are created, sent, received, and consumed in the java applications using JMS. It is a loosely coupled, reliable, and asynchronous mechanism for communication. JMS interfaces are implemented for message communication.

ActiveMQ is used for wealth portfolio management, network communications management, Data Distribution, Data Streaming, and Highway Toll management system applications. It can be used for sharing messages between more than one application or multiple application components. ActiveMQ has support for scheduling the sharing of messages.

2.7 Configuring the JMS client

JMS-based applications use message listeners for receiving the messages. Message Listener takes care of threading, receiving, dispatching, and processing the messages. Message Container acts as a middle man for Messaging providers and Messaging applications. Queue or Topics are used for sending messages and the message listener consumes them. Spring Framework has message listener containers that are DefaultMessageListenerContainer and SimpleMessageListenerContainer. DefaultMessageListenerContainer is based on a pull mechanism. SimpleMessageListenerContainer has push features for sending and consuming messages. DefaultMessageListenerContainer is recommended for many applications.

DefaultMessageListenerContainer does not block Messaging provider threads. It can recover from messaging failures and connection loss. It can support XA Transaction managers and XA transactions.SimpleMessageListenerContainer is used for native JMS applications without an XA manager. These applications use the JMS provider for thread management and connection recovery.

In the JMSMessageReceiverConfig class, you can create either of the container Factory classes (DefaultJMS or SimpleJMS). Both factory classes need Connection Factory. Concurrency options can be set using the setConcurrrency method on the MessageListenerContainer. Listener Container will have minimum number of consumers and increase to configured maximum number in the pool.

Endpoint definition is done in SimpleJmsListenerEndpoint class. It has Destination and MessageListener for message processing. StatusMessageListener is used for testing the containers with id as an identifier (DefaultJMS/SimpleJMS).

Let us look at the example for using spring with ActiveMQ.

you can start creating a maven project with the below pom.xml

ActiveMQ Example pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<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>org.javacodegeeks</groupId>
  <artifactId>activemq-example</artifactId>
  <version>0.0.1-SNAPSHOT</version>

  <name>activemq-example</name>
  <description>ActiveMQ Example</description>
  <url>https://www.javacodegeeks.com</url>

  <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.1.5.RELEASE</version>
    <relativePath />
  </parent>

  <properties>
    <java.version>8</java.version>
  </properties>

  <dependencies>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-activemq</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-test</artifactId>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
      </plugin>
    </plugins>
  </build>
</project>

You can create a spring application as shown below:

ActiveMQ Example
package org.javacodegeeks;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class ActiveMQExample {

  public static void main(String[] args) {
    SpringApplication.run(ActiveMQExample.class, args);
  }
}

You can now create JMSMessageReceiverConfig class as shown below:

JMSReceiverConfig
package org.javacodegeeks.jms;

import org.apache.activemq.ActiveMQConnectionFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jms.annotation.EnableJms;
import org.springframework.jms.config.DefaultJmsListenerContainerFactory;

@Configuration
@EnableJms
public class JMSMessageReceiverConfig {

  @Value("${activemq.broker-url}")
  private String brokerUrl;

  @Bean
  public ActiveMQConnectionFactory receiverActiveMQConnectionFactory() {
    ActiveMQConnectionFactory activeMQConnectionFactory =
        new ActiveMQConnectionFactory();
    activeMQConnectionFactory.setBrokerURL(brokerUrl);

    return activeMQConnectionFactory;
  }

  @Bean
  public DefaultJmsListenerContainerFactory jmsListenerContainerFactory() {
    DefaultJmsListenerContainerFactory factory =
        new DefaultJmsListenerContainerFactory();
    factory
        .setConnectionFactory(receiverActiveMQConnectionFactory());

    return factory;
  }

  @Bean
  public JMSMessageReceiver receiver() {
    return new JMSMessageReceiver();
  }
}

The JMSMessageReceiver class implementation is shown below:

JMSReceiver
package org.javacodegeeks.jms;

import java.util.concurrent.CountDownLatch;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jms.annotation.JmsListener;

public class JMSMessageReceiver {

  private static final Logger LOGGER =
      LoggerFactory.getLogger(JMSMessageReceiver.class);

  private CountDownLatch latch = new CountDownLatch(1);

  public CountDownLatch getLatch() {
    return latch;
  }

  @JmsListener(destination = "activemq.example")
  public void receive(String message) {
    LOGGER.info("received the message from sender '{}'", message);
    latch.countDown();
  }
}

2.8 Working with Spring’s JmsTemplate 

You can use JmsTemplate for producing messages and synchronous receiving of messages. Spring has message listener containers that can create MDPs (Message Driven POJOs). This is similar to Message Driven Bean Style. JmsTemplate can be used for sending messages. The destination can be a Queue or a Topic. send method is used for sending text messages. Custom Messages can be sent using convertAndSend method.

The JMSMessageSender class is shown below which implements JmsTemplate.

JMSSender
package org.javacodegeeks.jms;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsTemplate;

public class JMSMessageSender {

  private static final Logger LOGGER =
      LoggerFactory.getLogger(JMSMessageSender.class);

  @Autowired
  private JmsTemplate jmsTemplate;

  public void send(String message) {
    LOGGER.info("sending the message to receiver '{}'", message);
    jmsTemplate.convertAndSend("activemq.example", message);
  }
}

2.9 Consuming JMS from inside Spring

Spring Framework has features to consume messages from the JMS message producer. You can use MDP for listening to the JMS messages and receiving them from the JMS Provider. The Listener Container helps in calling the MDP listener triggered by the message. Spring AMQP (Advanced Messaging Queuing Protocol) can be used for integrating with Messaging system.

You can see the implementation of consuming JMS messages in the test class below:

ActiveMQExampleTest
package org.javacodegeeks;

import static org.assertj.core.api.Assertions.assertThat;
import java.util.concurrent.TimeUnit;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.javacodegeeks.jms.JMSMessageReceiver;
import org.javacodegeeks.jms.JMSMessageSender;

@RunWith(SpringRunner.class)
@SpringBootTest
public class ActiveMQExampleTest {

  @Autowired
  private JMSMessageSender sender;

  @Autowired
  private JMSMessageReceiver receiver;

  @Test
  public void testReceive() throws Exception {
    sender.send("Sending Message - Example Test");

    receiver.getLatch().await(10000, TimeUnit.MILLISECONDS);
    assertThat(receiver.getLatch().getCount()).isEqualTo(0);
  }
}

The above test can be executed after starting the activeMQ. ActiveMQ can be started by using the command below:

ActiveMQ start
./activemq start

You can execute the test by using the command below:

Run command for test
mvn test

The output is shown below:

Test Output
apples-MacBook-Air:activemqexample bhagvan.kommadi$ mvn test
[INFO] Scanning for projects...
[INFO] 
[INFO] ----------------------------------
[INFO] Building activemq-example 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ activemq-example ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ activemq-example ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-resources-plugin:3.1.0:testResources (default-testResources) @ activemq-example ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ activemq-example ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-surefire-plugin:2.22.2:test (default-test) @ activemq-example ---
[INFO] 
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running org.javacodegeeks.ActiveMQExampleTest
20:42:19.979 [main] DEBUG org.springframework.test.context.junit4.SpringJUnit4ClassRunner - SpringJUnit4ClassRunner constructor called with [class org.javacodegeeks.ActiveMQExampleTest]
20:42:19.987 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating CacheAwareContextLoaderDelegate from class [org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate]
20:42:20.002 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating BootstrapContext using constructor [public org.springframework.test.context.support.DefaultBootstrapContext(java.lang.Class,org.springframework.test.context.CacheAwareContextLoaderDelegate)]
20:42:20.047 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating TestContextBootstrapper for test class [org.javacodegeeks.ActiveMQExampleTest] from class [org.springframework.boot.test.context.SpringBootTestContextBootstrapper]
20:42:20.082 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Neither @ContextConfiguration nor @ContextHierarchy found for test class [org.javacodegeeks.ActiveMQExampleTest], using SpringBootContextLoader
20:42:20.094 [main] DEBUG org.springframework.test.context.support.AbstractContextLoader - Did not detect default resource location for test class [org.javacodegeeks.ActiveMQExampleTest]: class path resource [org/javacodegeeks/ActiveMQExampleTest-context.xml] does not exist
20:42:20.097 [main] DEBUG org.springframework.test.context.support.AbstractContextLoader - Did not detect default resource location for test class [org.javacodegeeks.ActiveMQExampleTest]: class path resource [org/javacodegeeks/ActiveMQExampleTestContext.groovy] does not exist
20:42:20.097 [main] INFO org.springframework.test.context.support.AbstractContextLoader - Could not detect default resource locations for test class [org.javacodegeeks.ActiveMQExampleTest]: no resource found for suffixes {-context.xml, Context.groovy}.
20:42:20.099 [main] INFO org.springframework.test.context.support.AnnotationConfigContextLoaderUtils - Could not detect default configuration classes for test class [org.javacodegeeks.ActiveMQExampleTest]: ActiveMQExampleTest does not declare any static, non-private, non-final, nested classes annotated with @Configuration.
20:42:20.170 [main] DEBUG org.springframework.test.context.support.ActiveProfilesUtils - Could not find an 'annotation declaring class' for annotation type [org.springframework.test.context.ActiveProfiles] and class [org.javacodegeeks.ActiveMQExampleTest]
20:42:20.325 [main] DEBUG org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider - Identified candidate component class: file [/Users/bhagvan.kommadi/Desktop/JavacodeGeeks/Code/activemqexample/target/classes/org/javacodegeeks/ActiveMQExample.class]
20:42:20.329 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Found @SpringBootConfiguration org.javacodegeeks.ActiveMQExample for test class org.javacodegeeks.ActiveMQExampleTest
20:42:20.525 [main] DEBUG org.springframework.boot.test.context.SpringBootTestContextBootstrapper - @TestExecutionListeners is not present for class [org.javacodegeeks.ActiveMQExampleTest]: using defaults.
20:42:20.526 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Loaded default TestExecutionListener class names from location [META-INF/spring.factories]: [org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener, org.springframework.test.context.web.ServletTestExecutionListener, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener, org.springframework.test.context.support.DependencyInjectionTestExecutionListener, org.springframework.test.context.support.DirtiesContextTestExecutionListener, org.springframework.test.context.transaction.TransactionalTestExecutionListener, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener]
20:42:20.543 [main] DEBUG org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Skipping candidate TestExecutionListener [org.springframework.test.context.web.ServletTestExecutionListener] due to a missing dependency. Specify custom listener classes or make the default listener classes and their required dependencies available. Offending class: [javax/servlet/ServletContext]
20:42:20.557 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Using TestExecutionListeners: [org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener@3d74bf60, org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener@4f209819, org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener@15eb5ee5, org.springframework.test.context.support.DirtiesContextTestExecutionListener@2145b572, org.springframework.test.context.transaction.TransactionalTestExecutionListener@39529185, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener@72f926e6, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener@3daa422a, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener@31c88ec8, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener@1cbbffcd, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener@27ce24aa, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener@481a996b]
20:42:20.567 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [org.javacodegeeks.ActiveMQExampleTest]
20:42:20.568 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [org.javacodegeeks.ActiveMQExampleTest]
20:42:20.570 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [org.javacodegeeks.ActiveMQExampleTest]
20:42:20.570 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [org.javacodegeeks.ActiveMQExampleTest]
20:42:20.571 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [org.javacodegeeks.ActiveMQExampleTest]
20:42:20.572 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [org.javacodegeeks.ActiveMQExampleTest]
20:42:20.581 [main] DEBUG org.springframework.test.context.support.AbstractDirtiesContextTestExecutionListener - Before test class: context [DefaultTestContext@192d43ce testClass = ActiveMQExampleTest, testInstance = [null], testMethod = [null], testException = [null], mergedContextConfiguration = [MergedContextConfiguration@72057ecf testClass = ActiveMQExampleTest, locations = '{}', classes = '{class org.javacodegeeks.ActiveMQExample}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true}', contextCustomizers = set[org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@56aac163, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@396f6598, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0, org.springframework.boot.test.web.client.TestRestTemplateContextCustomizer@57e1b0c, org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@0, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer@480bdb19], contextLoader = 'org.springframework.boot.test.context.SpringBootContextLoader', parent = [null]], attributes = map[[empty]]], class annotated with @DirtiesContext [false] with mode [null].
20:42:20.582 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [org.javacodegeeks.ActiveMQExampleTest]
20:42:20.582 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [org.javacodegeeks.ActiveMQExampleTest]
20:42:20.598 [main] DEBUG org.springframework.test.context.support.DependencyInjectionTestExecutionListener - Performing dependency injection for test context [[DefaultTestContext@192d43ce testClass = ActiveMQExampleTest, testInstance = org.javacodegeeks.ActiveMQExampleTest@62150f9e, testMethod = [null], testException = [null], mergedContextConfiguration = [MergedContextConfiguration@72057ecf testClass = ActiveMQExampleTest, locations = '{}', classes = '{class org.javacodegeeks.ActiveMQExample}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true}', contextCustomizers = set[org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@56aac163, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@396f6598, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0, org.springframework.boot.test.web.client.TestRestTemplateContextCustomizer@57e1b0c, org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@0, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer@480bdb19], contextLoader = 'org.springframework.boot.test.context.SpringBootContextLoader', parent = [null]], attributes = map[[empty]]]].
20:42:20.650 [main] DEBUG org.springframework.test.context.support.TestPropertySourceUtils - Adding inlined properties to environment: {spring.jmx.enabled=false, org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true, server.port=-1}

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.1.5.RELEASE)

2021-02-18 20:42:21.210  INFO 21809 --- [           main] org.javacodegeeks.ActiveMQExampleTest    : Starting ActiveMQExampleTest on apples-MacBook-Air.local with PID 21809 (started by bhagvan.kommadi in /Users/bhagvan.kommadi/Desktop/JavacodeGeeks/Code/activemqexample)
2021-02-18 20:42:21.214  INFO 21809 --- [           main] org.javacodegeeks.ActiveMQExampleTest    : No active profile set, falling back to default profiles: default
2021-02-18 20:42:23.978  INFO 21809 --- [           main] org.javacodegeeks.ActiveMQExampleTest    : Started ActiveMQExampleTest in 3.325 seconds (JVM running for 4.772)
2021-02-18 20:42:24.465  INFO 21809 --- [           main] org.javacodegeeks.jms.JMSMessageSender   : sending the message to receiver 'Sending Message - Example Test'
2021-02-18 20:42:24.619  INFO 21809 --- [enerContainer-1] o.javacodegeeks.jms.JMSMessageReceiver   : received the message from sender 'Sending Message - Example Test'
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 5.098 s - in org.javacodegeeks.ActiveMQExampleTest
[INFO] 
[INFO] Results:
[INFO] 
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  10.147 s
[INFO] Finished at: 2021-02-18T20:42:26+05:30
[INFO] ------------------------------------------------------------------------
apples-MacBook-Air:activemqexample bhagvan.kommadi$

3. Download the Source Code

Download
You can download the full source code of this example here: Spring ActiveMQ Example

Do you want to know how to develop your skillset to become a Java Rockstar?

Subscribe to our newsletter to start Rocking right now!

To get you started we give you our best selling eBooks for FREE!

 

1. JPA Mini Book

2. JVM Troubleshooting Guide

3. JUnit Tutorial for Unit Testing

4. Java Annotations Tutorial

5. Java Interview Questions

6. Spring Interview Questions

7. Android UI Design

 

and many more ....

 

Receive Java & Developer job alerts in your Area

 

Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Inline Feedbacks
View all comments