Giter Site home page Giter Site logo

module-ballerinax-ibm.ibmmq's Introduction

Ballerina ibm.ibmmq Library

Build codecov Trivy GitHub Last Commit

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.

Compatibility

Version
IBM MQ Server 9.3 or earlier
IBM MQ Client Connector 9.3.4.0

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://localhost:9443/ibmmq/console URL in your browser to access the IBM MQ console.
  2. Click on the Create a queue link.

Create a queue

  1. Select the queue type.

Select the queue type

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

Click on Manage

  1. Navigate to Events tab.

Navigate to Events tab

  1. 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.

import ballerinax/ibm.ibmmq;

Step 2: Instantiate a new connector

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

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.

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.

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

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

Produce messages to an IBM MQ topic

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

Retrieve messages from an IBM MQ queue

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

Retrieve messages from an IBM MQ topic

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

Step 4: Run the Ballerina application

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 MQIIH headers - Consume messages with the MQRFH2 header from an IBM MQ queue.

Issues and projects

Issues and Projects tabs are disabled for this repository as this is part of the Ballerina Standard Library. To report bugs, request new features, start new discussions, view project boards, etc., go to the Ballerina Standard Library parent repository.

This repository only contains the source code for the library.

Build from the source

Set up the prerequisites

  1. Download and install Java SE Development Kit (JDK) version 17 (from one of the following locations).

    • Oracle

    • OpenJDK

      Note: Set the JAVA_HOME environment variable to the path name of the directory into which you installed JDK.

  2. Generate a Github access token with read package permissions, then set the following env variables:

    export packageUser=<Your GitHub Username>
    export packagePAT=<GitHub Personal Access Token>
  3. Download and install Docker. This is required to run the tests.

Build the source

Execute the commands below to build from the source.

  1. To build the library:

    ./gradlew clean build
    
  2. To run the tests:

    ./gradlew clean test
    
  3. To build the library without the tests:

    ./gradlew clean build -x test
    
  4. To debug library implementation:

    ./gradlew clean build -Pdebug=<port>
    
  5. To debug the library with Ballerina language:

    ./gradlew clean build -PbalJavaDebug=<port>
    
  6. Publish ZIP artifact to the local .m2 repository:

    ./gradlew clean build publishToMavenLocal
    
  7. Publish the generated artifacts to the local Ballerina central repository:

    ./gradlew clean build -PpublishToLocalCentral=true
    
  8. Publish the generated artifacts to the Ballerina central repository:

    ./gradlew clean build -PpublishToCentral=true
    

Contribute to Ballerina

As an open source project, Ballerina welcomes contributions from the community.

For more information, go to the contribution guidelines.

Code of conduct

All the contributors are encouraged to read the Ballerina Code of Conduct.

Useful links

module-ballerinax-ibm.ibmmq's People

Contributors

ayeshlk avatar dilansachi avatar maheshika avatar nipunaranasinghe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.