JMS stands for Java Message Service which is a standard for accessing messaging middleware servers in Java. This is a JMS introduction tutorial to give you a brief overview of messaging and JMS. You will learn the advantages of using JMS, different messaging models in JMS.

What is messaging?

Messaging is a process of exchanging Business data across various applications or services. Messages are usually asynchronous requests, responses, reports or events that are consumed by other applications or services. These messages contain vital information.

Messaging is what gives scalability power to a micro-services architecture. Messaging is also traditionally used in a service-oriented architecture to establish asynchronous and reliable communications between them.

A messaging system is also known as a Message Oriented middleware Products. There are several available today like ActiveMQ, RabbitMQ, ActiveMQ Artemis, Apache Kafka, Application Servers (Glassfish, Wildfly, WebsphereMQ) and etc are messaging middleware.

Advantages of using a Messaging middleware

  • Reliability – Messaging middleware guarantees delivery. If the consumer is down for some reason, the messaging system stores the message until it is up again.
  • Asynchronous – JMS is asynchronous, the sender and receiver need not wait for each other.
  • Ease of Integration – Multiple applications can be written in different programming languages or running on different servers. As long as they use the same protocol, a messaging middleware can be used to establish communications between them.
  • Scalability – Messaging helps in broadcasting to multiple receivers which help in scalability.
  • Flexibility – You can assign different protocols to different messages, which allows you a lot of flexibility in designing your architecture.

What is JMS (Java Message Service)?

There are several Enterprise messaging middleware (Message-oriented middleware) products today like TIBCO MQ, Apache ActiveMQ, Apache Kafka, RabbitMQ, ActiveMQ Artemis, IBM MQ and so on.

JMS provides a standard Java API meaning a common way for Java Programs to create, send, receive and read Enterprise messaging system’s messages. We will explore the JMS 1.x and 2.0 API standards.

Not all Enterprise messaging middleware implements JMS standards. The middlewares that implement JMS standard are known as JMS providers. Several of them are Apache ActiveMQ, Apache ActiveMQ Artem, Oracle WebLogic Server, Glassfish, IBM MQ, Jboss Wildfly, Apache Qpid and so on. No matter which implementation you use, if you stick to the JMS standard switching the vendors is simple.

JMS is not interoperable, meaning it is mainly for applications written in Java or JVM languages. If you want to use a messaging protocol that has better interoperability support (which can work in NodeJS, Python, C# etc), please look into AMQP (Advanced Message Queuing Protocol) e.g. RabbitMQ.

Limitations of JMS standard

The JMS standard does not include the following functionalities, cause JMS is just about sending and receiving messages.

  1. Load Balancing/Fault Tolerant
  2. Error/Advisory notification
  3. Administration API for JMS providers
  4. Security
  5. No message type repository definitions

Messaging models in JMS

JMS supports 2 major styles of messaging and they are as discussed below. We will only discuss the types here as part of the JMS introduction, later part of the tutorial will cover each type with several examples.

  • Point-to-Point (PTP) – In PTP model, a sender sends a message to another client (receiver) via an intermediator called Queue. Only a single receiver reads the message.
  • Publish and Subscribe (pub/sub) – In Pub/Sub model, the client sends a message to multiple receivers via an intermediator called Topic. Sender publishes messages to a specific topic and multiple receivers subscribe to that topic.

Components of a JMS application

A typical JMS application is composed of several parts as below.

  • JMS Clients – The Java code that sends and receives messages.
  • Non-JMS Clients – Makes use of the system’s native API.
  • Messages – The business data that is being sent or received.
  • JMS Provider – A messaging system that implements JMS as well as other administrative functionalities. Also known a MOM (Message Oriented Middleware).
  • Administrative Objects – They are basically Destinations (Queues, Topics) and connection factories that are preconfigured in the JMS provider.

Security features in JMS

JMS does not provide features for controlling or configuring message integrity or message privacy. It is expected that many JMS providers will provide such features. This will be handled by JMS providers with specific administration tools.

Now that you got a high-level understanding of messaging and JMS as part of this JMS introduction tutorial. Next, we will install and set up a JMS messaging server.