Markdown

JMS

JMS is the Acronym for Java Message Service

A Java application programming interface (API) for message-oriented middleware, the Jakarta Messaging (formerly Java Message Service or JMS) provides generic messaging models to facilitate the sending and receiving of messages between software systems. It is part of Jakarta EE and was originally defined by a specification developed at Sun Microsystems before being guided by the Java Community Process.

Core Concepts

JMS is designed to enable asynchronous communication between software components, allowing senders and receivers to operate independently.

  • Asynchronous Communication: The sender does not need to wait for the receiver to process the message, enabling immediate task switching.
  • Loosely Coupled: The sender and receiver only need to agree on the message format and destination (the queue or topic), not each other’s internal workings.
  • Reliability: JMS ensures that messages are delivered exactly once or at least once, depending on the configuration, even if the network or system fails temporarily.

Messaging Models

JMS primarily supports two patterns of communication:

  • Point-to-Point (PTP): Built around Queues. Each message is addressed to a specific queue, and only one consumer receives the message, which stays in the queue until it is consumed or expires.
  • Publish-Subscribe (Pub/Sub): Built around Topics. A sender publishes a message to a topic, and multiple subscribers who are interested in that topic receive a copy of that message.

Key Components

  • JMS Provider: The messaging system (middleware) that implements the JMS interfaces (e.g., Apache ActiveMQ, RabbitMQ, or IBM MQ).
  • JMS Client: The Java application or component that produces or consumes messages.
  • Administered Objects: Preconfigured JMS objects (Destinations and Connection Factories) created by an administrator for the client to use.
  • Message: The actual data being moved, consisting of a header, optional properties, and a body (text, bytes, or objects).

Use Cases

In modern microservices or enterprise environments, JMS is used to handle bursty traffic. For example, an e-commerce site might use JMS to send order details to a shipping service. If the shipping service is slow or down, the order isn't lost, it sits safely in the JMS queue until the service is back online.

Articles Tagged JMS

View Additional Articles Tagged JMS