Skip to content

JMS (Java Message Service) Bindings

The Java Message Service (JMS) is a Java API that allows applications to create, send, receive, and read messages. It provides a common way for Java programs to create portable, message-based applications for the enterprise. The AsyncAPI JMS bindings allow you to describe the configuration of your JMS-based systems in a standardized way.

JMS is a specification, not an implementation. It defines a set of interfaces that message-oriented middleware (MOM) vendors implement. This allows for loose coupling between applications and the messaging system.

Key concepts include:

  • Destinations: The objects that applications send messages to and receive messages from. JMS defines two types:
    • Queues (Point-to-Point): Each message has only one consumer.
    • Topics (Publish/Subscribe): Each message can have multiple subscribers.
  • ConnectionFactory: An object that encapsulates connection configuration information, which a client uses to create a connection to a JMS provider.
  • Messages: Composed of headers (metadata), properties (application-specific), and a body (the payload).
  • Producers & Consumers: Clients that send messages to and receive messages from destinations.

The JMS bindings provide a way to map AsyncAPI concepts to specific JMS provider configurations.

Binding Type Purpose Description
Channel Binding Destination Configuration Defines a channel as a JMS Queue and specifies its properties.
Operation Binding (Placeholder) Reserved for future JMS-specific operation properties.
Message Binding Header & Property Configuration Defines JMS-specific headers (like JMSCorrelationID) and properties for a message.
Server Binding Connection Factory Configuration Specifies the JMS ConnectionFactory class and its properties, including the clientID.

An AsyncAPI channel maps to a JMS Destination. The channel binding allows you to specify whether the destination is a standard queue or a fifo-queue for providers that support strict ordering.

channels:
orderProcessingQueue:
bindings:
jms:
bindingVersion: '0.0.1'
destination: 'orders'
destinationType: 'queue'

The message binding is crucial for defining the standard JMS headers that provide metadata for routing and tracking. This includes headers like JMSMessageID, JMSCorrelationID, and JMSReplyTo, which are essential for implementing patterns like request/reply.

messages:
orderRequest:
bindings:
jms:
headers:
type: object
properties:
JMSReplyTo:
type: string

The server binding is used to configure the client’s entry point to the JMS provider: the ConnectionFactory. You must specify the Java class for the factory and can provide additional provider-specific properties.

servers:
activemq:
url: tcp://broker.example.com:61616
protocol: jms
bindings:
jms:
bindingVersion: '0.0.1'
jmsConnectionFactory: 'org.apache.activemq.ActiveMQConnectionFactory'
clientID: 'my-app-1'

Versions and changes

Generated from the binding JSON Schemas: every field each version added or removed.

VersionWhat changedPages
0.0.1latest

First version: server binding, channel binding, message binding.

server, channel, operation, message

Fields in version 0.0.1

Server binding

FieldTypeDescription
propertiesarrayAdditional properties to set on the JMS ConnectionFactory implementation for the JMS Provider
properties[].namerequiredstringThe name of a property
properties[].valuerequiredstring | boolean | number | nullThe name of a property
clientIDstringA client identifier for applications that use this JMS connection factory. If the Client ID Policy is set to 'Restricted' (the default), then configuring a Client ID on the ConnectionFactory prevents more than one JMS client from using a connection from this factory
jmsConnectionFactoryrequiredstringThe classname of the ConnectionFactory implementation for the JMS Provider

Server binding 0.0.1: examples and details

Channel binding

FieldTypeDescription
destinationstringThe destination (queue) name for this channel. SHOULD only be specified if the channel name differs from the actual destination name, such as when the channel name is not a valid destination name according to the JMS Provider. Defaults to the channel name
destinationTypestring
queuefifo-queue
The type of destination. SHOULD be specified to document the messaging model (point-to-point, or strict message ordering) supported by this channel

Channel binding 0.0.1: examples and details

Message binding

FieldTypeDescription
headersSchema ObjectA Schema object containing the definitions for JMS headers (protocol headers). This schema MUST be of type 'object' and have a 'properties' key. Examples of JMS protocol headers are 'JMSMessageID', 'JMSTimestamp', and 'JMSCorrelationID'

Message binding 0.0.1: examples and details

Validate with JSON Schema

Point your editor, CI or AI agent at these schemas to validate the Jakarta Messaging API (JMS) bindings of version 0.0.1. They come from the AsyncAPI JSON Schema registry.

Questions

Can AsyncAPI describe JMS?

Yes. The JMS server binding names the jmsConnectionFactory class and its properties, the channel binding sets destination and destinationType (queue or fifo-queue), and the message binding defines JMS headers.

How do I document JMS headers such as JMSCorrelationID?

As a schema in the headers field of the JMS message binding: an object whose properties are the header names, for example JMSCorrelationID or JMSExpiration.