All Products
Search
Document Center

ApsaraMQ for RabbitMQ:Overview

Last Updated:Sep 08, 2023

ApsaraMQ for RabbitMQ provides a Java Message Service (JMS) client library for JMS clients to connect to ApsaraMQ for RabbitMQ. This topic introduces the concepts related to the JMS client library provided by ApsaraMQ for RabbitMQ. This topic also describes the limits of the JMS client library and shows how to obtain and use the library.

Background information

JMS is a messaging standard that allows application components based on Java Platform, Enterprise Edition (Java EE) to create, send, receive, and read messages. JMS enables communication between distributed applications in a loosely coupled, reliable, and asynchronous manner. The JMS client library provided by ApsaraMQ for RabbitMQ supports JMS 1.1.

JMS library of ApsaraMQ for RabbitMQ

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

For information about differences between JMS and AMQP, see JMS and AMQP.

Obtain the JMS client library

  • Add the following dependency to the pom.xml file in your 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

  • Server sessions are not supported.

  • The interfaces for eXtended Architecture (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 protocol provided by JMS clients for ApsaraMQ 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 may call a method that contains the NoLocal argument. However, the call is ignored.

For information about the implementation of the JMS API provided by ApsaraMQ for RabbitMQ, see Compatibility.

Tutorial

Messaging pattern

Description

References

P2P

The JMS point-to-point (P2P) messaging pattern has the following characteristics:

  • Each message can be consumed by only the specified consumer. After a producer sends a message to a queue, a specified consumer registered for the queue can receive the message.

  • No timing dependencies exist between producers and consumers. Producers can send messages to queues regardless of whether consumers are active. Consumers can receive messages from queues regardless of whether producers are active.

Pub/Sub

The publish-subscribe (Pub/Sub) messaging pattern has the following characteristics:

  • Each message can be subscribed to by multiple consumers. After a publisher publishes a message to a topic, all subscribers that subscribe to the topic can consume the message.

  • Timing dependencies exist between publishers and subscribers.

    • If a subscriber creates a non-persistent subscription, the subscriber must subscribe to a topic before a publisher publishes a message to the topic. In addition, the subscriber must remain active to consume all messages sent to the topic. If a message is published when the subscriber is inactive, the subscriber cannot consume the message even after the subscriber becomes active.

    • If a subscriber creates a persistent subscription, the subscriber must subscribe to a topic before a publisher publishes a message to the topic. However, the subscriber does not need to remain active to consume all messages sent to the topic. If a message is published when the subscriber is inactive, the subscriber can still consume the message after the subscriber becomes active.