Ajax JQuery + SpringBoot RestAPI + ActiveMQ Producer/Consumer example

In the tutorial, we show how to Producer/Consumer data from ActiveMQ with JQuery & SpringBoot RestAPIs.

Related posts:
How to integrate JQuery Ajax POST/GET & Spring MVC | Spring Boot
ActiveMQ Producer/Consumer + SpringBoot RestAPIs example
RabbitMq – How to create Spring RabbitMq Publish/Subcribe pattern with SpringBoot
How to use Spring Kafka JsonSerializer (JsonDeserializer) to produce/consume Java Object messages


  • Java 1.8
  • Maven 3.3.9
  • Spring Tool Suite – Version 3.9.4.RELEASE
  • Spring Boot: 2.0.3.RELEASE
  • ActiveMQ
  • JQuery


We create a Spring JMS ActiveMQ with JMS Producer & JMS Consumer as below:

JQuery-SpringBoot-RestAPI-ActiveMQ-Producer-Consumer + project-structure

JQuery-SpringBoot-RestAPI-ActiveMQ-Producer-Consumer + producer-consumer

Then expose RestAPIs to POST/GET data to/from ActiveMQ:

  • @PostMapping(value="/api/task")
  • @GetMapping(value="/api/tasks")

Use JQuery Client to submit/get data from ActiveMQ via above RestAPI:

JQuery-SpringBoot-RestAPI-ActiveMQ-Producer-Consumer + results

ActiveMQ state:

JQuery-SpringBoot-RestAPI-ActiveMQ-Producer-Consumer + ActiveMQ-state


Setup SpringBoot project

Use SpringToolSuite to create a SpringBoot project with below dependencies:

ActiveMQ Connection Factory

ActiveMqConnectionFactoryConfig ->

Add ActiveMQ configuration in application.properties ->

Data Model

– Create Task model ->

– Create MessageStorage to storage Task list ->

Create a bean for MessageStorage ->

JMS Producer

JmsProducer send messages to ActiveMQ ->

JMS Consumer

JmsConsumer recieves messages from ActiveMQ ->

Rest APIs

RestAPI ->


/src/main/resources/templates/index.html ->

Post/Get Ajax JQuery

resources/static/js/postrequest.js ->

resources/static/js/getrequest.js ->



By grokonez | August 13, 2018.

Related Posts

Got Something To Say:

Your email address will not be published. Required fields are marked *