From the course: Spring: Messaging with JMS

Understanding JMS 1.1 Spec - Spring Tutorial

From the course: Spring: Messaging with JMS

Start my 1-month free trial

Understanding JMS 1.1 Spec

- [Instructor] Before we dive in to Spring JMS, let's take a quick look at the Java messaging service spec, the two domain types of messaging, and some example uses. The JMS spec is a set of interfaces and terms that defines how a JMS client can access the facilities of an enterprise product. Looking over at the official documentation, you'll see here on the JMS spec is a great resource for any developer to consider. Feel free to browse this for more fine grain details. Third party products are providers that implement the JMS specification, will furnish the needed coded in the implementations for accessing a message oriented middleware product called a MOM. Messaging in general then allows for transmission of specifically formatted messages to a MOM for temporary retention before being accessed by another client. Published MOMs are in synchronized communication between a MOM and other JMS client applications. I know it sounds funny, but there are many various MOMs, or Message Oriented Middleware products like ActiveMQ, RabbitMZ, Jboss, StormMQ and even Oracle allows for queue creation inside of its database. Honestly, there are really too many to try to list them all. Later in the Spring JMS tutorials, we will publish messages to a topic and queues using ActiveMQ. There are two domain types of JMS messaging which are point to point, and publish subscribe systems. Point to point systems operate around message queues where a message is published to a specific queue on a MOM and a separate client is established to listen and consume only from that queue on that MOM. Peer to peer systems operate around message queues where a message is published to a specific queue on the MOM and a specific client is established to listen and consume only from that queue on the MOM. Let's look at some examples breaking down how point to point and Pub/Sub work. So the point to point messaging domain type is useful when you communicate to only one consumer with the queue or task or messages to be operated upon. For example, a storefront may place a request for a product that is in the warehouse inventory. That request for the product is published to a particular queue on a MOM. And in our case, ActiveMQ. We'll call that queue the order request queue. The warehouse client system listens to the order request queue and pulls the message or the request from the queue and acts upon it. In a point to point each message is designed to be sent to a particular queue on the MOM that a specified client is designed to receive. The Pub/Sub message domain type similarly involves publishing a message but instead of to a queue that is only for one and only one consumer, it publishes to a topic on a MOM. That topic can have multiple subscribers. Using the storefront warehouse example again, imagine that there are several storefronts that have subscribed to an inventory topic on an ActiveMQ server, our MOM. We'll apply call this topic the inventory topic. The warehouse client application would publish to the inventory topic messages that convey warehouse items that have been removed or added to the inventory. Storefront clients then, which have subscribed to the inventory topic on the MOM are then able to determine what items are available for order and store those inventory changes locally. Okay, since we have now refreshed our understanding of JMS and queue and topic basics, let's look at what Spring JMS is and why we might want to use it over JMS in general.

Contents