Module ibm.ibmmq

ballerinax/ibm.ibmmq Ballerina library

1.0.0

Overview

IBM MQ is a powerful messaging middleware platform designed for facilitating reliable communication between disparate systems and applications. IBM MQ ensures the secure and orderly exchange of messages asynchronously, decoupling senders and receivers for efficient and scalable communication. It supports both point-to-point and publish/subscribe messaging models via queues and topics.

The ballerinax/ibm.ibmmq package provides an API to connect to an IBM MQ server using Ballerina. The current connector is compatible with IBM MQ server versions up to 9.3.

Setup guide

To use the Ballerina IBM MQ connector, you need to have an IBM MQ instance running or possess an IBM MQ cloud account. For setting up IBM MQ locally, you can refer to the IBM MQ official documentation. Alternatively, to use IBM MQ on the cloud, sign up for an IBM MQ cloud account.

Create a queue

  1. Log into IBM MQ console. If you are running an IBM MQ server locally you can navigate to https://<host>:<port>/ibmmq/console URL in your browser to access the IBM MQ console.

  2. Click on the Create a queue link.

    Create a queue
  3. Select the queue type.

    Select the queue type

Create a topic

  1. Go back to the home page and click on the Manage link on the sidebar.

    Click on manage
  2. Navigate to Events tab.

    Navigate to events tab
  3. Click on Create.

    Click on create

Quickstart

To use the IBM MQ connector in your Ballerina application, modify the .bal file as follows:

Step 1: Import the connector

Import ballerinax/ibm.ibmmq module into your Ballerina project.

Copy
import ballerinax/ibm.ibmmq;

Step 2: Instantiate a new connector

Create an ibmmq:QueueManager instance by giving IBM MQ configuration.

Copy
configurable string queueManagerName = ?;
configurable string host = ?;
configurable int port = ?;
configurable string channel = ?;
configurable string userID = ?;
configurable string password = ?;

ibmmq:QueueManager queueManager = check new (
    name = queueManagerName, host = host, channel = channel, userID = userID, password = password
);

Create an ibmmq:Queue or ibmmq:Topic using the ibmmq:QueueManager instance with relevant configurations.

Copy
configurable string queueName = ?;

ibmmq:Queue queue = check queueManager.accessQueue(queueName, ibmmq:MQOO_OUTPUT | ibmmq:MQOO_INPUT_AS_Q_DEF);

Create an ibmmq:Topic using the ibmmq:QueueManager instance with relevant configurations.

Copy
configurable string topicName = ?;
configurable string topicString = ?;

ibmmq:Topic topic = check queueManager.accessTopic(
    topicName, topicString, ibmmq:MQOO_OUTPUT | ibmmq:MQOO_INPUT_AS_Q_DEF
);

Step 3: Invoke the connector operations

Now, utilize the available connector operations.

Produce messages to an IBM MQ queue

Copy
check queue->put({
    payload: "This is a sample message to IBM MQ queue".toBytes()
});

Produce messages to an IBM MQ topic

Copy
check topic->put({
    payload: "This is a sample message to IBM MQ topic".toBytes()
});

Retrieve messages from an IBM MQ queue

Copy
ibmmq:Message? message = check queue->get();

Retrieve messages from an IBM MQ topic

Copy
ibmmq:Message? message = check topic->get();

Step 4: Run the Ballerina application

Copy
bal run

Examples

The following example shows how to use the ibm.ibmmq connector to produce and consume messages using an IBM MQ server.

  1. Produce messages - Produce messages to an IBM MQ queue.

  2. Consume messages - Consume messages from an IBM MQ queue.

  3. Securing IBM MQ client - Initiate secure communication between an IBM MQ client and an IBM MQ server.

  4. Produce MQIIH headers - Produce IBM MQ messages to an IBM MQ queue with the MQIIH headers.

  5. Consume MQIIH headers - Consume messages with the MQIIH header from an IBM MQ queue.

  6. Produce MQRFH2 headers - Produce IBM MQ messages to an IBM MQ queue with the MQRFH2 headers.

  7. Consume MQRFH2 headers - Consume messages with the MQRFH2 header from an IBM MQ queue.

Import

import ballerinax/ibm.ibmmq;Copy

Metadata

Released date: 3 months ago

Version: 1.0.0

License: Apache-2.0


Compatibility

Platform: java17

Ballerina version: 2201.8.0


Pull count

Total: 0

Current verison: 0


Weekly downloads


Source repository


Keywords

ibm.ibmmq

client

messaging

network

pubsub


Contributors

Other versions

1.0.0