Developing AMQP client applications

The IBM MQ support for AMQP APIs, including the MQ Light API, allows an IBM MQ administrator to create an AMQP channel. When it is started, this channel defines a port number that accepts connections from AMQP client applications.

We can install an AMQP channel on UNIX, Linux, or Windows; it is not available on IBM i or z/OS .

The MQ Light API is based on the Oasis AMQP 1.0 protocol. There are messaging APIs for Node.js, Java, Ruby and Python.

An application that is developed to use the MQ Light API can be connected to either an MQ Light runtime, an IBM MQ queue manager with an AMQP channel, or an instance of an MQ Light service in IBM Cloud.


Developing AMQP clients

The MQ Light API aims to make it easier to prototype and develop business applications rapidly. There are MQ Light APIs for Node.js, Java, Ruby and Python, available at https://github.com/mqlight.


Developing applications using the Apache Qpid JMS library

Introduction

The Apache Qpid JMS library uses the AMQP 1.0 protocol to provide an implementation of the JMS 2 specification.

Apache Qpid JMS uses some aspects of the AMQP 1.0 protocol in a different way from the MQ Light messaging APIs. IBM MQ Version 9.2 adds support to IBM MQ AMQP channels, so that Apache Qpid JMS applications are able to connect to IBM MQ and do publish/subscribe messaging, including the use of shared subscriptions.

Intercommunication with other IBM MQ applications

It is possible to send messages between Apache Qpid JMS applications and other IBM MQ applications. For example, an Apache Qpid application can publish messages on a topic, and MQ Light applications can receive them by creating a subscription.

An Apache Qpid JMS application can also publish messages that are consumed by traditional IBM MQ applications, for example using the MQSUB API call to subscribe to the same topic.

Similarly, Apache Qpid JMS applications can subscribe to IBM MQ topics that traditional IBM MQ applications publish messages on.

It is also possible for an Apache Qpid JMS application to share a subscription with an MQ Light application, as long as both clients specify the same share name and topic pattern.

Note that, in order to do this, the Apache Qpid JMS application must not connect with a client ID. This ensures that the IBM MQ subscription name used by both of the applications is the same.

Attention: It is not possible for an Apache Qpid JMS application to share a subscription with an IBM MQ JMS application.

Apache Qpid JMS restrictionsThe following JMS capabilities are supported:

  • Connect with or without credentials
  • Create a consumer on a topic destination
  • Create a durable consumer on a topic destination
  • Create a shared consumer on a topic destination
  • Create a shared durable consumer on a topic destination
  • Client acknowledge and auto-acknowledge modes
  • Message acknowledgment and session acknowledgment
  • Unsubscribing from a durable subscription

The following JMS capabilities are not supported by AMQP clients:

  • The use of message selectors
  • The use of the nolocal attribute
  • Send or receiving messages to queue destinations
  • The use of transacted sessions
  • The use of delivery delay


Downloading sample AMQP clients

IBM MQ does not ship MQ Light clients, but we can download and install the following MQ Light clients:

    Node.js
    Install MQ Light Node.js API to your working directory using npm: npm install mqlight@1.0

    Java
    Download the mqlight-distribution package for the required version from Maven Central and extract the contents. We can find the available versions of the mqlight-distribution packages on Maven Central.

    Ruby
    Install MQ Light Ruby API to your working directory using gem: gem install mqlight --pre

    Python
    Install MQ Light Python API to your working directory using pip: pip install mqlight --pre

The MQ Light client downloads all include several samples, which demonstrate the different messaging features:

  • Send sample
  • Receive sample
  • UI Workout sample

We can also download other open-source AMQP clients based on Apache Qpid libraries. For more information, see https://qpid.apache.org/index.html.


Deploying AMQP clients to IBM MQ

When an application is ready to deploy, it requires all of the monitoring, reliability, and security capabilities of other enterprise applications. It can also exchange data with other enterprise applications. We can deploy MQ Light applications to an IBM MQ queue manager. See Deploying MQ Light applications to an on-premises IBM MQ environment .

When you have deployed an AMQP client, we can exchange messages with IBM MQ applications. For example, if we use the MQ Light Node.js client to send a JavaScript string message, the IBM MQ application receives an MQ message, where the format field of the MQMD is set to MQSTR.


Manage the AMQP channel

The AMQP channel can be managed in the same way as other MQ channels. We can use MQSC commands, PCF command messages, or IBM MQ Explorer to define, start, stop, and manage the channels. In Create and using AMQP channels, example commands are provided to define and start connecting clients to a queue manager.

When an AMQP channel is started, we can test it by connecting an MQ Light application, using any of the following methods:

  • Use the IBM MQ Light client for Node.js and Java.
  • Use the IBM MQ Light client for Ruby and Python.
  • Use another AMQP Version 1.0 client. For example, Apache Qpid Proton.


Related information