HDTutorial
EN

Playback starts YouTube’s embedded player (privacy-enhanced mode).

Spring Boot JMS Tutorial - JmsTemplate JmsListener with ActiveMQ Example & JAXB

30,955 views October 31, 2016 21:18

Watch on YouTube
ChannelPhilip Starritt

Chapters

Description from the creator

In this Java Spring JMS Example I show you how to use Spring Boot JMS Autoconfiguration in order to create a JMS producer and JMS consumer.

We first create a JMS publisher application by injecting the Spring Boot JmsTemplate autoconfiguration with a MarshallingMessageConverter and ActiveMQ connection factory (also autoconfigured). The MarshallingMessageConverter contains a Jaxb2Marshaller with its context path, schema and pretty print values set. The context path is equal to the package that contains the JAXB generated objects.

I then create a JMS consumer application by configuring a MarshallingMessageConverter backed by a Jaxb2Marshaller. The ActiveMQ connection factory will also be autoconfigured in the consumer. Once these are configured, Spring Boot will automatically create a JmsListenerContainerFactory and associate our defined beans (Above). We can then use the @JmsListener annotation to read of a target message queue. See spring documentation 13.1.6 for more information.

The publisher will automatically convert & marshall the JAXB object into XML before sending it to the ActiveMQ message queue. The consumer will additionally automatically unmarshal the XML into the JAXB object.

0:00 – 01:15 Tutorial overview
00:15 – 01:42 Create maven dependency for shared JAXB Objects.
01:42 – 02:55 Maven JAXB plugin – Generate JAXB objects from XSD
02:55 – 03:45 Create Jms Publisher Spring Starter Project
03:45 – 04:40 Analyse Spring Boot JmsAutoConfiguration JmsTemplate
04:40 – 06:30 Set Spring Boot ActiveMQ autoconfiguration & application properties
06:30 – 10:00 Configure MarshallingMessageConverter and Jaxb2Marshaller. Set the context path, enable schema validation and XML pretty print
10:00 – 12:35 Send Message to ActiveMQ queue via JmsTemplate. Start ActiveMQ Message Broker via Windows Command Prompt
12:35 – 14:30 Debug and analyse objects to show spring boot autowiring
14:40 – 15:40 Create Jms Consumer Spring Starter Project & configure maven dependencies
15:40 – 16:36 Configure Jms consumer MarshallingMessageConverter and Jaxb2Marshaller. Set the context path, enable schema validation and XML pretty print
16:36 – 16:45 Remove AMQP dependency from Publisher (brought in my accident)
16:55 – 17:15 Add @EnableJms to the spring configuration
17:15 – 18:50 Add @JmsListener annotation to read and process messages of the ActiveMQ
18:50 – 19:40 Turn on JMS consumer and consume XML message. Automatically convert XML into JAXB object.
19:40 – 20:10 Turn on publisher and send another message to consumer
20:10 – 20:17 Tutorial summary

If you enjoyed the tutorial please subscribe for regular Software Tutorials! :)

Enjoy!
Philip

Spring Framework JMS Example

Apache Camel Alternative Tutorial: youtube.com/watch?v=B-Q_InvRvn0

Jaxb2Marshaller Tutorial: youtube.com/watch?v=0D-P2LzLJYQ

Spring Boot Messaging Features: docs.spring.io/spring-boot/docs/current/referen…

Spring Framework JMS Integration: docs.spring.io/spring/docs/current/spring-frame…

JmsTemplate: docs.spring.io/spring-framework/docs/current/ja…

ActiveMQ: activemq.apache.org/

ActiveMQ Spring Support: activemq.apache.org/spring-support.html

Spring JMS ActiveMQ Example

About this tutorial

Philip Starritt published this 21:18 video tutorial on October 31, 2016. It has been watched 30,955 times on YouTube.

Category
Education
Duration
21:18
Published
October 31, 2016
Views
30,955
Likes
193

Tags

Share

This tutorial in other languages