Message Queue for RabbitMQ provides a Java Message Service (JMS) client library for JMS applications to connect to Message Queue for RabbitMQ. This article describes the common concepts and limits of the JMS client library that Message Queue for RabbitMQ provides. This article also introduces how to obtain and use the JMS client library.

JMS client library of Message Queue for RabbitMQ

The JMS client library of Message Queue for RabbitMQ is the JMS API provided by Message Queue for RabbitMQ. To connect JMS applications to Message Queue for RabbitMQ by using this library, you need to change only a small amount of code. Then, JMS applications can use Message Queue for RabbitMQ as a JMS provider. You can use the JMS client library of Message Queue for RabbitMQ to create JMS connections, sessions, producers, and consumers.

For more information about JMS and AMQP, see JMS and AMQP.

Call methods

You can use one of the following methods to call the JMS client library of Message Queue for RabbitMQ:

  • Add the following dependency to the pom.xml file in the Maven project:
    <dependency>
        <groupId>com.alibaba.mq-amqp.jms</groupId>
        <artifactId>mq-amqp-jms-client</artifactId>
        <version>1.11.2-1.0.0</version>
        <exclusions>
            <exclusion>
                <groupId>com.rabbitmq</groupId>
                <artifactId>amqp-client</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
  • Download the JAR file of the dependency.

Limits

The JMS client library of Message Queue for RabbitMQ has the following limits:

  • Server sessions are not supported.
  • The interfaces for XA transactions are not implemented.
  • Topic selectors are supported. Queue selectors are not implemented.
  • Secure Sockets Layer (SSL) and socket options are provided. However, only the default SSL connection protocols provided by JMS clients for Message Queue for RabbitMQ can be used.
  • The NoLocal subscription feature is not supported. This feature prevents a subscriber from publishing messages from its own connection. You can call a method that contains the NoLocal argument. However, but the call will be ignored.

For more information about the implementation of the JMS API for Message Queue for RabbitMQ, see Compatibility.

Tutorial

The following table describes how to use the JMS client library of Message Queue for RabbitMQ.

Messaging model Description Documentation
P2P The JMS point-to-point (P2P) messaging model has the following features:
  • Each message has only one consumer. After a producer sends a message to a queue, a specified consumer registered for the queue can receive the message.
  • Producers and consumers have no timing dependencies. Producers can send messages to queues regardless of whether consumers are active. Consumers can receive messages from queues regardless of whether producers are active.
JMS P2P
Pub/Sub The Publish/Subscribe (Pub/Sub) messaging model has the following features:
  • Each message can have multiple consumers. After a producer sends a message to a topic, all subscribers of the topic can consume the message.
  • Producers and subscribers have timing dependencies.
    • If a subscriber creates a nondurable subscription, the subscriber must subscribe to a topic before a producer sends a message to the topic. In addition, the subscriber must remain active to consume all the messages sent to the topic. If a message is sent when the subscriber is inactive, the subscriber cannot consume the message after it becomes active.
    • If a subscriber creates a durable subscription, the subscriber must subscribe to a topic before a producer sends a message to the topic. However, the subscriber does not need to remain active to consume all the messages sent to the topic. If a message is sent when the subscriber is inactive, the subscriber can consume the message after it becomes active.
JMS Pub/Sub