Giter Club home page Giter Club logo

activemqreceiver's Introduction

Spring Boot with ActiveMQ 5

This is a demo project demonstrating Spring Boot with ActiveMQ using Topics. Here we have the receiver which is listening for messages in a specific topic.

Configuration

In application.properties file you can see how we set the properties for ActiveMQ. We are using the default username and password (admin/admin). In order to use Topics (broadcast) and not Queues (serial) we have to set to TRUE the following property:

spring.jms.pub-sub-domain

We also set the name of the topic here, using a custom property name (destination.name).

Receiving messages from topic

In order to receive a message from the topic, we have to annotate our receiver class (Receiver.java) with the @EnableJms annotation. Then we can use a function to specify the name of the topic from which we want to receive a message from, using the @JmsListener annotation and passing as parameter the name of the topic (we have already set it in our application.properties file). This part is done here:

@JmsListener(destination = "${destination.name}")
public void showReceivedMessage(String message) {
	logger.info("Message received: {} ", message);
}

and pretty much that is all.

Run the application

Open a console window and run the following commands while inside the project folder:

mvn clean package
java -jar target/amqReceiver-0.0.1-SNAPSHOT.jar

Keep in mind that you have to start the ActiveMQ first: For Windows users:

  • Download it and extract it
  • Go to <downloaded_folder>/bin/<win_version>
  • Run activeqm.bat

For Linux and Mac: Follow the manual :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.