Chapter 2. Understanding message-oriented middleware and JMS
Enterprise messaging emerged as a practical solution to the growing problem of connecting disparate systems that differed in hardware, operating systems, protocols, and data formats. As business applications became more distributed and demanding in areas such as performance, scalability, reliability, and security, message-oriented middleware provided a way to mediate communication through asynchronous message exchange. This approach reduced the maintenance burden of point-to-point adapters and enabled systems to communicate without being tightly coupled, making it especially valuable for mission-critical environments.
Within this model, messages carry business information between senders and receivers through destinations, while the middleware handles delivery, routing, persistence, and transformation. The Java Message Service standardized access to these capabilities for Java developers by defining a vendor-neutral API, rather than being a messaging system itself. JMS introduced a common set of concepts such as producers, consumers, connections, destinations, administered objects, and messages, helping developers write portable messaging applications while still allowing JMS providers to offer additional features beyond the core specification.
The chapter also explains how JMS messages are structured and used in practice. Messages include headers and properties that support delivery controls, correlation, filtering, and custom metadata, while the payload can take several forms such as text, bytes, maps, streams, or objects. JMS supports both point-to-point queues and publish/subscribe topics, along with patterns like durable subscriptions and request/reply messaging. It concludes by showing the basic JMS workflow for sending and receiving messages, both synchronously and asynchronously, and by introducing message-driven beans as an enterprise Java mechanism for consuming messages automatically and concurrently.
Standalone terminals connecting to a mainframe using a single protocol
Standalone terminals and applications connecting to a mainframe using many protocols.
Message-oriented middleware mediates messages to the mainframe and guarantees message delivery.
JMS allows a single client to easily connect to many JMS providers.
A graphical representation of a JMS message
Listing 2.4. A JMS message with custom properties
Point-to-point messaging uses a one-to-one messaging paradigm.
Publish/subscribe uses a one-to-many messaging paradigm.
FAQ
What is enterprise messaging and why is it important?Enterprise messaging is a way for applications to exchange business data by sending messages instead of making direct, tightly coupled calls. It is important because it supports reliability, scalability, loose coupling, and integration across different systems, platforms, and protocols.What is message-oriented middleware (MOM)?MOM is software that mediates communication between distributed applications in an asynchronous, loosely coupled, reliable, scalable, and secure way. It helps systems communicate even when they use different data formats, operating systems, protocols, or programming languages.How does MOM improve communication between applications?MOM acts as an intermediary between senders and receivers, allowing them to communicate without needing to be connected at the same time. It also adds features such as persistence, routing, transformation, and support for unreliable or slow connections.What is JMS?The Java Message Service (JMS) is a standardized Java API for sending and receiving messages in a vendor-neutral way. It is not a MOM itself, but an abstraction layer that lets Java applications work with different messaging providers more easily.What are the main JMS concepts defined by the specification?JMS defines concepts such as JMS client, producer, consumer, provider, message, domains, administered objects, connection factory, and destination. These concepts form the foundation for building messaging applications in Java.What is the difference between a JMS producer and a JMS consumer?A JMS producer is a client that creates and sends messages, while a JMS consumer receives and processes them. A single JMS client can act as both producer and consumer.What are the two main JMS messaging domains?The two main JMS domains are point-to-point and publish/subscribe. Point-to-point uses queues and delivers each message to one consumer, while publish/subscribe uses topics and delivers messages to all subscribers.What is the role of JMS message headers and properties?Message headers and properties store metadata about a message, such as destination, delivery mode, expiration, priority, correlation ID, and custom filtering data. They help control delivery behavior and enable message selectors.What are message selectors used for?Message selectors let consumers filter messages based on headers and properties using SQL92-style conditional expressions. They are useful when a consumer only wants messages that match specific criteria, such as a symbol or price threshold.What is a message-driven bean (MDB) and how is it used with JMS?An MDB is an EJB component that automatically consumes JMS messages asynchronously through the MessageListener interface. It allows the EJB container to manage resources, transactions, and concurrency, making it easier to process messages in a Java EE environment.
pro $24.99 per month
access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!