Bookmark this page

Chapter 8.  Configuring the Messaging Subsystem

Abstract

Goal

Describe the messaging architecture and configure various messaging resources.

Objectives
  • Describe the Java Messaging Service and the architecture of the messaging subsystem.

  • Configure connection factories and destinations.

  • Configure messaging journals and other messaging subsystem settings.

Sections
  • Exploring the Messaging Subsystem (and Quiz)

  • Configuring Messaging Resources (and Guided Exercise)

  • Configure Journals and Other Settings (and Guided Exercise)

Lab
  • Configuring the Messaging Subsystem

Exploring the Messaging Subsystem

Objectives

  • Describe the Java Messaging Service and the architecture of the messaging subsystem.

Messaging Concepts

Messaging is the basis of many enterprise integration patterns and has been a central piece of application architecture for decades. Regardless of age, messaging technology is on the rise because of cloud and mobile applications. Messaging patterns provide a loosely-coupled communication mechanism for software components. These patterns enable the software components to process different tasks in an asynchronous manner. This loose coupling eases business process changes and can improve application scalability and resiliency.

Messaging middleware, also known as Message-Oriented Middleware (MOM), is responsible for application message management and delivery. MOMs typically provide features such as security, routing, guaranteed delivery, classes of services, and transactions.

MOMs can be embedded within other products, much like the way Red Hat JBoss Enterprise Application Platform (JBoss EAP) 7 embeds a MOM based on ActiveMQ Artemis. A MOM can also be a standalone server, requiring its own specialized management, tuning, and clustering.

For example, consider the checkout process for a web store that triggers the following actions:

  • Authorization and payment confirmation

  • Addition and removal of inventory

  • Delivery scheduling

These actions take time to process, so executing within a checkout request means users might have a long wait for order confirmation. However, these actions do not necessarily need to be performed right away. In other words, they can be performed asynchronously.

For example, the checkout action could instead send a message to a payment application and return to the user instantly. Similarly, once the payment is confirmed, then a message could be sent to an inventory component. Finally, the delivery component could initiate its tasks upon receiving a message.

With such an architecture, each action is potentially handled by separate components. This spreads the capacity needs amongst all of the components and potentially reduces system-wide bottlenecks.

Even if an action cannot be completed right away, then the action can be postponed without canceling the entire process or an alternative process flow can be triggered. This adds resistance to issues outside of the organization, as well. For example, an transient error from an external payment processor does not require failure of the entire order.

Overview of the Java Messaging Service (JMS)

The Java Message Service (JMS) is a specification for Java components to send and receive messages without being directly connected to one another. JMS provides a standardized API for accessing MOM services, much like JDBC provides a standardized API for accessing relational databases. JMS also defines common semantics that a MOM is expected to follow. This relieves applications from being dependent on particular product idiosyncrasies.

The JMS API is based on the following resource types:

  • Connection factories encapsulate the connection to a MOM. Jakarta EE 7 states that a default ConnectionFactory is provided by the application server. Because of this, applications can be deployed before having messaging connection parameters. Administrators can configure additional ConnectionFactories to fulfill server-specific application needs or to point to external MOMs.

  • Queues send and receive messages that are retrieved in a first-in, first-out (FIFO) basis. A producer places a message in the queue, and a single consumer removes the message.

  • Topics implement a publish-subscribe method where multiple subscribed consumers can receive messages published to the topic. If a consumer is offline, the MOM retains messages for later delivery to that particular consumer.

JMS refers to both queues and topics as destinations. Many message operations, such as sending a message, apply to both queues and topics.

Applications refer to destinations by using a JNDI name. This name is under the control of the application server administrator, which facilitates message redirection without changing application source code. This eases business process changes for features implemented via messaging.

JMS ConnectionFactories are also referenced by using a JNDI name. This way applications can be directed to different MOMs, or even different products. Developers commonly do so by way of connecting the application to an embedded MOM during development, but to an external MOM in production.

Jakarta Connectors for External MOMs

Like JDBC, the JMS API is available outside of a Jakarta EE application server. In this case, the application needs to embed the JMS provider specific to the MOM. However, there is no standard way to package and load this provider.

Inside of an application server, the JMS API collaborates with the Jakarta Connectors (JCA) API to provide a portable way to package the JMS provider as a Resource Adapter Archive (RAR) that is deployable to any certified Jakarta EE application server.

Much like JDBC drivers, RAR files are generic middleware drivers, but are not tied to specific kinds of middleware. Different vendors provide RAR files for connecting Jakarta EE application servers to their middleware products, such as ERP systems and transaction monitors. The JMS specification builds on this JCA capability instead of duplicating it, unlike JDBC, whose origins predate Jakarta EE.

The JMS Message Structure

The JMS message structure consists of the following parts:

  • Message headers are created and processed by the MOM. The JMS API defines headers that applications can use, but they are usually treated as part of the MOM infrastructure, In most cases, application logic should not rely on these headers.

  • Message properties are defined by the producer as a way to pass metadata to both the MOM and consumers. One use of a property value is to determine which consumer should receive a message. For example, a web store could use properties to deliver orders to different payment processing systems.

  • Message bodies contain application-specific data that a MOM should avoid handling itself. In JMS, messages are transformed by regular client applications, not the MOM infrastructure.

An Introduction to JBoss EAP Built-in Messaging

The following are the current messaging offerings from Red Hat:

Red Hat AMQ

Broker and clients for a MOM system based on ActiveMQ, ActiveMQ Artemis, HornetQ, QPid, and other consolidated open source message components.

Red Hat AMQ Streams

MOM system based on Apache Kafka.

For more information about these messaging products, see the references section.

The messaging server embedded in JBoss EAP incorporate components from ActiveMQ Artemis, and leaves other components out, such as those that provide support for the STOMP and AMQP protocols. Native client libraries for languages other than Java are also absent in JBoss EAP.

From a product standpoint, Red Hat intendeds for JBoss EAP messaging to be a general messaging and integration platform. Meanwhile, Red Hat AMQ and Red Hat AMQ Streams are intended as complete JMS messaging server solutions.

Although some Jakarta EE application server vendors provide an embedded JMS server that is only for development and small scale production use, this is not the case for JBoss EAP. Because JBoss EAP JMS server has a focus on the Jakarta EE ecosystem, it does not support every available protocol. However, it provides full enterprise support, and is capable of dealing with high-performance and critical production scenarios.

To use Red Hat JBoss AMQ instead, you must install the AMQ JCA Resource Adaptor and configure JMS connection factories.

The ActiveMQ Messaging Subsystem

ActiveMQ Artemis is the messaging-activemq subsystem embedded into JBoss EAP 7. ActiveMQ is managed by using the management CLI and console.

Activating the messaging-activemq subsystem implies using either the standalone-full.xml or standalone-full-ha.xml configuration files for standalone server mode, or either the full or full-ha profiles for managed domains.

The subsystem contains two child objects in the default JBoss EAP 7 configuration, exemplified by the following CLI command:

[domain@127.0.0.1:9990 /] /profile=full/subsystem=messaging-activemq:read-resource
{
    "outcome" => "success",
    "result" => {
        ...output omitted...
        "jms-bridge" => undefined,
        ...output omitted...
        "server" => {"default" => undefined},
        ...output omitted...
    }
}

The jms-bridge contains bridges that automatically transfer messages between the embedded JMS server and any other JMS server known by the JBoss EAP 7 domain. This also includes servers from other vendors. The standard configuration files do not provide a default bridge.

The server=default is the embedded JMS server. It contains a number of attributes and child objects that configure all MOM aspects, such as JMS resources, networking, storage, and clustering.

Clustering the ActiveMQ Subsystem

Clustering with ActiveMQ is different from JBoss EAP clustering because it supports a number of different approaches, such as in-memory replication and shared storage. This course does not detail all alternative configurations.

The default ActiveMQ clustering configuration does not use Infinispan for replication. This is the same in the standalone-full-ha.xml configuration file and the full-ha profile. Instead of using Infinispan, the ActiveMQ server automatically creates bridges that connect cluster members. The server employs a message distribution algorithm where cluster members without consumers do not receive any replication traffic.

Creating bridges requires shared authentication credentials stored in the cluster-password attribute. The default JBoss EAP configuration files set this attribute based on the value of the jboss.messaging.cluster.password system property.

By default, applications deployed into an JBoss EAP server instance connect to the local messaging server to avoid network overhead. They are not affected by clustering configurations in the sense that their messaging server fails if the JBoss EAP server fails. Nothing prevents administrators from configuring JMS ConnectionFactories that connect to remote servers. In that case, the JBoss EAP server works just like any other remote client.

Connections are distributed amongst cluster members so that no single messaging server becomes a bottleneck. Remote JMS clients find messaging cluster members the same way that cluster members find one another: by using JGroups. Remote JMS client connections automatically fail over to a surviving cluster member. When this occurs, messages are not lost in the process.

References

JSR 343: JMS Specification

ActiveMQ Project

Red Hat AMQ Overview

Red Hat AMQ Streams

For more information about using Jakarta Connectors in resource adapters format, see the Resource Adapters chapter in the Configuring Messaging guide of the Red Hat documentation at https://access.redhat.com/documentation/en-us/red_hat_jboss_enterprise_application_platform/7.4/html-single/configuring_messaging/index#resource_adapters

For more information about ActiveMQ embedded in JBoss EAP, see the ActiveMQ Artemis section in the Configuring Messaging guide of the Red Hat documentation at Configuring Messaging

Revision: ad248-7.4-18a9db2