From 45dd2e3acde3619fe0c267cde3c3ce00f8d84baf Mon Sep 17 00:00:00 2001 From: ayeshLK Date: Mon, 30 Oct 2023 09:24:09 +0530 Subject: [PATCH 1/8] Update API docs for queue-manager,constants and record types --- ballerina/constants.bal | 120 ++++++++++++++++++++++++++---------- ballerina/errors.bal | 3 +- ballerina/queue_manager.bal | 28 +++++++++ ballerina/types.bal | 35 +++++++++-- 4 files changed, 147 insertions(+), 39 deletions(-) diff --git a/ballerina/constants.bal b/ballerina/constants.bal index f5e4b0e..fdef860 100644 --- a/ballerina/constants.bal +++ b/ballerina/constants.bal @@ -14,37 +14,89 @@ // specific language governing permissions and limitations // under the License. -// Option to indicate whether the topic is being opened for either publication or subscription. -public const OPEN_AS_SUBSCRIPTION = 1; -public const OPEN_AS_PUBLICATION = 2; - -// Options that control the opening of the queue for a consumer. -public const MQOO_BROWSE = 8; -public const MQOO_INPUT_AS_Q_DEF = 1; -public const MQOO_INPUT_EXCLUSIVE = 4; -public const MQOO_INPUT_SHARED = 2; - -// Options that control the opening of the topic for either publication or subscription. -public const MQOO_ALTERNATE_USER_AUTHORITY = 4096; -public const MQOO_BIND_AS_Q_DEF = 0; -public const MQOO_FAIL_IF_QUIESCING = 8192; -public const MQOO_OUTPUT = 16; -public const MQOO_PASS_ALL_CONTEXT = 512; -public const MQOO_PASS_IDENTITY_CONTEXT = 256; -public const MQOO_SET_ALL_CONTEXT = 2048; -public const MQOO_SET_IDENTITY_CONTEXT = 1024; - -// Options related to the the get message in a topic. -public const MQGMO_WAIT = 1; -public const MQGMO_NO_WAIT = 0; -public const MQGMO_SYNCPOINT = 2; -public const MQGMO_NO_SYNCPOINT = 4; -public const MQGMO_BROWSE_FIRST = 16; -public const MQGMO_BROWSE_NEXT = 32; -public const MQGMO_BROWSE_MSG_UNDER_CURSOR = 2048; -public const MQGMO_MSG_UNDER_CURSOR = 256; -public const MQGMO_LOCK = 512; -public const MQGMO_UNLOCK = 1024; -public const MQGMO_ACCEPT_TRUNCATED_MSG = 64; -public const MQGMO_FAIL_IF_QUIESCING = 8192; -public const MQGMO_CONVERT = 16384; +# Open topic as a subscription. +public const int OPEN_AS_SUBSCRIPTION = 1; + + # Open topic as a publication. +public const int OPEN_AS_PUBLICATION = 2; + +# Open the queue to browse messages. +public const int MQOO_BROWSE = 8; + +# Open the queue to get messages using the queue-defined default. +public const int MQOO_INPUT_AS_Q_DEF = 1; + +# Open the queue to get messages with exclusive access. +public const int MQOO_INPUT_EXCLUSIVE = 4; + +# Open the queue to get messages with shared access. +public const int MQOO_INPUT_SHARED = 2; + +# Enables the AlternateUserId field in the ObjDesc parameter contains a user identifier to use to validate this MQOPEN call. +public const int MQOO_ALTERNATE_USER_AUTHORITY = 4096; + +# The local queue manager binds the queue handle in the way defined by the DefBind queue attribute. +public const int MQOO_BIND_AS_Q_DEF = 0; + +# The MQOPEN call fails if the queue manager is in quiescing state. This option is valid for all types of object. +public const int MQOO_FAIL_IF_QUIESCING = 8192; + +# This allows the MQPMO_PASS_ALL_CONTEXT option to be specified in the PutMsgOpts parameter when a message is put on a queue. +public const int MQOO_PASS_ALL_CONTEXT = 512; + +# This allows the MQPMO_PASS_IDENTITY_CONTEXT option to be specified in the PutMsgOpts parameter when a message is put on a queue. +public const int MQOO_PASS_IDENTITY_CONTEXT = 256; + +# This allows the MQPMO_SET_ALL_CONTEXT option to be specified in the PutMsgOpts parameter when a message is put on a queue. +public const int MQOO_SET_ALL_CONTEXT = 2048; + +# This allows the MQPMO_SET_IDENTITY_CONTEXT option to be specified in the PutMsgOpts parameter when a message is put on a queue. +public const int MQOO_SET_IDENTITY_CONTEXT = 1024; + +# Open the queue to put messages. +public const int MQOO_OUTPUT = 16; + +# The application waits until a suitable message arrives. +public const int MQGMO_WAIT = 1; + +# The application does not wait if no suitable message is available. +public const int MQGMO_NO_WAIT = 0; + +# The request is to operate within the normal unit-of-work protocols. +public const int MQGMO_SYNCPOINT = 2; + +# The request is to operate outside the normal unit-of-work protocols. +public const int MQGMO_NO_SYNCPOINT = 4; + +# When a queue is opened with the MQOO_BROWSE option, a browse cursor is established, positioned logically +# before the first message on the queue. +public const int MQGMO_BROWSE_FIRST = 16; + +# Advance the browse cursor to the next message on the queue that satisfies the selection criteria specified +# on the MQGET call. +public const int MQGMO_BROWSE_NEXT = 32; + +# Retrieve the message pointed to by the browse cursor nondestructively, regardless of the MQMO_* options +# specified in the MatchOptions field in MQGMO. +public const int MQGMO_BROWSE_MSG_UNDER_CURSOR = 2048; + +# Retrieve the message pointed to by the browse cursor, regardless of the MQMO_* options specified in the +# MatchOptions field in MQGMO. +public const int MQGMO_MSG_UNDER_CURSOR = 256; + +# Lock the message that is browsed, so that the message becomes invisible to any other handle open for the queue. +public const int MQGMO_LOCK = 512; + +# Unlock a message. The message to be unlocked must have been previously locked by an MQGET call with the +# MQGMO_LOCK option. +public const int MQGMO_UNLOCK = 1024; + +# If the message buffer is too small to hold the complete message, allow the MQGET call to fill the +# buffer with as much of the message as the buffer can hold. +public const int MQGMO_ACCEPT_TRUNCATED_MSG = 64; + +# Force the MQGET call to fail if the queue manager is in the quiescing state. +public const int MQGMO_FAIL_IF_QUIESCING = 8192; + +# Requests the application data to be converted. +public const int MQGMO_CONVERT = 16384; diff --git a/ballerina/errors.bal b/ballerina/errors.bal index 2438af3..0f08d8e 100644 --- a/ballerina/errors.bal +++ b/ballerina/errors.bal @@ -14,9 +14,10 @@ // specific language governing permissions and limitations // under the License. +# Represents a IBM MQ distinct error. public type Error distinct error; -# The error details type for the module. +# The error details type for the IBM MQ module. # # + reasonCode - The reason code for the error # + errorCode - The error code for the error diff --git a/ballerina/queue_manager.bal b/ballerina/queue_manager.bal index 19261df..953acbb 100644 --- a/ballerina/queue_manager.bal +++ b/ballerina/queue_manager.bal @@ -16,8 +16,16 @@ import ballerina/jballerina.java; +# Represents an IBM MQ queue manager. public isolated class QueueManager { + # Initialize an IBM MQ queue manager. + # ```ballerina + # ibmmq:QueueManager queueManager = check new(name = "QM1", host = "localhost", channel = "DEV.APP.SVRCONN"); + # ``` + # + # + configurations - The configurations to be used when initializing the IBM MQ queue manager + # + return - The `ibmmq:QueueManager` or an `ibmmq:Error` if the initialization failed public isolated function init(*QueueManagerConfiguration configurations) returns Error? { check self.externInit(configurations); } @@ -27,11 +35,31 @@ public isolated class QueueManager { 'class: "io.ballerina.lib.ibm.ibmmq.QueueManager" } external; + # Establishes access to an IBM MQ queue on this queue manager. + # ```ballerina + # ibmmq:Queue queue = check queueManager.accessQueue("queue1", ibmmq:MQOO_OUTPUT); + # ``` + # + # + queueName - Name of the queue + # + options - The options which control the opening of the queue + # + return - The `ibmmq:Queue` object or an `ibmmq:Error` if the operation failed public isolated function accessQueue(string queueName, AccessQueueOptions options) returns Queue|Error = @java:Method { 'class: "io.ballerina.lib.ibm.ibmmq.QueueManager" } external; + # Establishes access to an IBM MQ topic on this queue manager. + # ```ballerina + # ibmmq:Topic topic = check queueManager.accessTopic( + # "dev", "DEV.BASE.TOPIC", ibmmq:OPEN_AS_PUBLICATION, ibmmq:MQOO_OUTPUT + # ); + # ``` + # + # + topicName - The topic string to publish or subscribe against + # + topicString - The name of the topic object as defined on the local queue manager + # + openTopicOption - Indicates whether the topic is being opened for either publication or subscription + # + options - Options that control the opening of the topic for either publication or subscription + # + return - The `ibmmq:Topic` object or an `ibmmq:Error` if the operation failed public isolated function accessTopic(string topicName, string topicString, OPEN_TOPIC_OPTION openTopicOption, AccessTopicOptions options) returns Topic|Error = @java:Method { diff --git a/ballerina/types.bal b/ballerina/types.bal index f8e4547..2df4e5a 100644 --- a/ballerina/types.bal +++ b/ballerina/types.bal @@ -14,10 +14,28 @@ // specific language governing permissions and limitations // under the License. -public type GM_OPTIONS MQGMO_WAIT|MQGMO_NO_WAIT|MQGMO_SYNCPOINT|MQGMO_NO_SYNCPOINT|MQGMO_BROWSE_FIRST|MQGMO_BROWSE_MSG_UNDER_CURSOR|MQGMO_MSG_UNDER_CURSOR|MQGMO_LOCK|MQGMO_UNLOCK|MQGMO_ACCEPT_TRUNCATED_MSG|MQGMO_BROWSE_NEXT|MQGMO_ACCEPT_TRUNCATED_MSG|MQGMO_FAIL_IF_QUIESCING|MQGMO_CONVERT; +# Options which can be provided when retrievinge messages from an IBM MQ destination. +public type GM_OPTIONS MQGMO_WAIT|MQGMO_NO_WAIT|MQGMO_SYNCPOINT|MQGMO_NO_SYNCPOINT|MQGMO_BROWSE_FIRST| + MQGMO_BROWSE_MSG_UNDER_CURSOR|MQGMO_MSG_UNDER_CURSOR|MQGMO_LOCK|MQGMO_UNLOCK|MQGMO_ACCEPT_TRUNCATED_MSG| + MQGMO_BROWSE_NEXT|MQGMO_ACCEPT_TRUNCATED_MSG|MQGMO_FAIL_IF_QUIESCING|MQGMO_CONVERT; +# Options which can be provided when opening an IBM MQ topic. public type OPEN_TOPIC_OPTION OPEN_AS_SUBSCRIPTION|OPEN_AS_PUBLICATION; +# Options which can be provided when accessing an IBM MQ queue. +public type AccessQueueOptions MQOO_OUTPUT|MQOO_BROWSE|MQOO_INPUT_AS_Q_DEF|MQOO_INPUT_EXCLUSIVE|MQOO_INPUT_SHARED; + +# Options which can be provided when accessing an IBM MQ topic. +public type AccessTopicOptions MQOO_ALTERNATE_USER_AUTHORITY|MQOO_BIND_AS_Q_DEF|MQOO_FAIL_IF_QUIESCING|MQOO_OUTPUT|MQOO_PASS_ALL_CONTEXT|MQOO_PASS_IDENTITY_CONTEXT|MQOO_SET_ALL_CONTEXT|MQOO_SET_IDENTITY_CONTEXT; + +# IBM MQ queue manager configurations. +# +# + name - Name of the queue manager +# + host - IBM MQ server host +# + port - IBM MQ server port +# + channel - IBM MQ channel +# + userID - IBM MQ userId +# + password - IBM MQ user password public type QueueManagerConfiguration record {| string name; string host; @@ -27,19 +45,28 @@ public type QueueManagerConfiguration record {| string password?; |}; -public type AccessQueueOptions MQOO_OUTPUT|MQOO_BROWSE|MQOO_INPUT_AS_Q_DEF|MQOO_INPUT_EXCLUSIVE|MQOO_INPUT_SHARED; -public type AccessTopicOptions MQOO_ALTERNATE_USER_AUTHORITY|MQOO_BIND_AS_Q_DEF|MQOO_FAIL_IF_QUIESCING|MQOO_OUTPUT|MQOO_PASS_ALL_CONTEXT|MQOO_PASS_IDENTITY_CONTEXT|MQOO_SET_ALL_CONTEXT|MQOO_SET_IDENTITY_CONTEXT; - +# IBM MQ get message options. +# +# + gmOptions - Get message option +# + waitInterval - Waiting interval to retrieve messages public type GetMessageOptions record {| GM_OPTIONS gmOptions = MQGMO_NO_SYNCPOINT; int waitInterval = 0; |}; +# Represents an IBM MQ message property. +# +# + descriptor - Property descriptor +# + value - Property value public type Property record {| map descriptor?; boolean|byte|byte[]|decimal|float|int|string value; |}; +# Represents an IBM MQ message. +# +# + properties - Message properties +# + payload - Message payload public type Message record {| map properties; byte[] payload; From 8bc09ff58097bd3acdb86bbda40bd53aa62580dc Mon Sep 17 00:00:00 2001 From: ayeshLK Date: Mon, 30 Oct 2023 09:29:04 +0530 Subject: [PATCH 2/8] Update API docs for IBM MQ destination clients --- ballerina/destination.bal | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/ballerina/destination.bal b/ballerina/destination.bal index 25e864d..67a618c 100644 --- a/ballerina/destination.bal +++ b/ballerina/destination.bal @@ -15,35 +15,56 @@ // under the License. import ballerina/jballerina.java; +# IBM MQ destination client type. public type Destination distinct client object { remote function put(Message message) returns Error?; remote function get(*GetMessageOptions options) returns Message|Error?; }; +# IBM MQ Queue client. public isolated client class Queue { *Destination; + # Puts a message to an IBM MQ queue. + # + # + message - IBM MQ message + # + return - An `ibmmq:Error` if the operation fails or else `()` remote function put(Message message) returns Error? = @java:Method { 'class: "io.ballerina.lib.ibm.ibmmq.Queue" } external; - remote function get(*GetMessageOptions options) returns Message|Error = + # Retrieves a message from an IBM MQ queue. + # + # + options - Options to control message retrieval + # + return - An `ibmmq:Message` if there is any message in the queue, `()` if there + # is no message or else `ibmmq:Error` if the operation fails + remote function get(*GetMessageOptions options) returns Message|Error? = @java:Method { 'class: "io.ballerina.lib.ibm.ibmmq.Queue" } external; } +# IBM MQ Topic client. public isolated client class Topic { *Destination; + # Puts a message to an IBM MQ topic. + # + # + message - IBM MQ message + # + return - An `ibmmq:Error` if the operation fails or else `()` remote function put(Message message) returns Error? = @java:Method { 'class: "io.ballerina.lib.ibm.ibmmq.Topic" } external; - remote function get(*GetMessageOptions options) returns Message|Error = + # Retrieves a message from an IBM MQ topic. + # + # + options - Options to control message retrieval + # + return - An `ibmmq:Message` if there is any message in the queue, `()` if there + # is no message or else `ibmmq:Error` if the operation fails + remote function get(*GetMessageOptions options) returns Message|Error? = @java:Method { 'class: "io.ballerina.lib.ibm.ibmmq.Topic" } external; From 295fb2eb638a138106b2f624c106571c3a388f6b Mon Sep 17 00:00:00 2001 From: ayeshLK Date: Mon, 30 Oct 2023 10:11:17 +0530 Subject: [PATCH 3/8] Update API documentation --- ballerina/types.bal | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ballerina/types.bal b/ballerina/types.bal index 2df4e5a..c6ffaff 100644 --- a/ballerina/types.bal +++ b/ballerina/types.bal @@ -48,10 +48,11 @@ public type QueueManagerConfiguration record {| # IBM MQ get message options. # # + gmOptions - Get message option -# + waitInterval - Waiting interval to retrieve messages +# + waitInterval - The maximum time (in milliseconds) that an `get` call waits for a suitable message to +# arrive. It is used in conjunction with `ibmmq.MQGMO_WAIT`. public type GetMessageOptions record {| GM_OPTIONS gmOptions = MQGMO_NO_SYNCPOINT; - int waitInterval = 0; + int waitInterval = 0; |}; # Represents an IBM MQ message property. From 1c4e32a59483c33413defb115ce25080537ebf1f Mon Sep 17 00:00:00 2001 From: ayeshLK Date: Mon, 30 Oct 2023 12:40:07 +0530 Subject: [PATCH 4/8] Update PR template --- .github/pull_request_template.md | 10 ++++++ issue_template.md | 18 ----------- pull_request_template.md | 52 -------------------------------- 3 files changed, 10 insertions(+), 70 deletions(-) create mode 100644 .github/pull_request_template.md delete mode 100644 issue_template.md delete mode 100644 pull_request_template.md diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..c440bcd --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,10 @@ +## Purpose + +## Examples + +## Checklist +- [ ] Linked to an issue +- [ ] Updated the changelog +- [ ] Added tests +- [ ] Updated the spec +- [ ] Checked native-image compatibility diff --git a/issue_template.md b/issue_template.md deleted file mode 100644 index 757e13e..0000000 --- a/issue_template.md +++ /dev/null @@ -1,18 +0,0 @@ -**Description:** - - -**Suggested Labels:** - - -**Suggested Assignees:** - - -**Affected Product Version:** - -**OS, DB, other environment details and versions:** - -**Steps to reproduce:** - - -**Related Issues:** - \ No newline at end of file diff --git a/pull_request_template.md b/pull_request_template.md deleted file mode 100644 index 9b32185..0000000 --- a/pull_request_template.md +++ /dev/null @@ -1,52 +0,0 @@ -## Purpose -> Describe the problems, issues, or needs driving this feature/fix and include links to related issues in the following format: Resolves issue1, issue2, etc. - -## Goals -> Describe the solutions that this feature/fix will introduce to resolve the problems described above - -## Approach -> Describe how you are implementing the solutions. Include an animated GIF or screenshot if the change affects the UI (email documentation@wso2.com to review all UI text). Include a link to a Markdown file or Google doc if the feature write-up is too long to paste here. - -## User stories -> Summary of user stories addressed by this change> - -## Release note -> Brief description of the new feature or bug fix as it will appear in the release notes - -## Documentation -> Link(s) to product documentation that addresses the changes of this PR. If no doc impact, enter “N/A” plus brief explanation of why there’s no doc impact - -## Training -> Link to the PR for changes to the training content in https://github.com/wso2/WSO2-Training, if applicable - -## Certification -> Type “Sent” when you have provided new/updated certification questions, plus four answers for each question (correct answer highlighted in bold), based on this change. Certification questions/answers should be sent to certification@wso2.com and NOT pasted in this PR. If there is no impact on certification exams, type “N/A” and explain why. - -## Marketing -> Link to drafts of marketing content that will describe and promote this feature, including product page changes, technical articles, blog posts, videos, etc., if applicable - -## Automation tests - - Unit tests - > Code coverage information - - Integration tests - > Details about the test cases and coverage - -## Security checks - - Followed secure coding standards in http://wso2.com/technical-reports/wso2-secure-engineering-guidelines? yes/no - - Ran FindSecurityBugs plugin and verified report? yes/no - - Confirmed that this PR doesn't commit any keys, passwords, tokens, usernames, or other secrets? yes/no - -## Samples -> Provide high-level details about the samples related to this feature - -## Related PRs -> List any other related PRs - -## Migrations (if applicable) -> Describe migration steps and platforms on which migration has been tested - -## Test environment -> List all JDK versions, operating systems, databases, and browser/versions on which this feature/fix was tested - -## Learning -> Describe the research phase and any blog posts, patterns, libraries, or add-ons you used to solve the problem. \ No newline at end of file From 8c03ed74f0915917b188a60c521494472513717b Mon Sep 17 00:00:00 2001 From: ayeshLK Date: Mon, 30 Oct 2023 12:40:36 +0530 Subject: [PATCH 5/8] Update package readme --- README.md | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 86 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9a89291..2e85f18 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,86 @@ -# module-ballerinax-ibm.ibmmq -Ballerina IBM MQ client connector module. +# Ballerina `ibm.ibmmq` Library + +[![Build](https://github.com/ballerina-platform/module-ballerinax-ibm.ibmmq/actions/workflows/build-timestamped-master.yml/badge.svg)](https://github.com/ballerina-platform/module-ballerinax-ibm.ibmmq/actions/workflows/build-timestamped-master.yml) +[![codecov](https://codecov.io/gh/ballerina-platform/module-ballerinax-ibm.ibmmq/branch/main/graph/badge.svg)](https://codecov.io/gh/ballerina-platform/module-ballerinax-ibm.ibmmq) +[![Trivy](https://github.com/ballerina-platform/module-ballerinax-ibm.ibmmq/actions/workflows/trivy-scan.yml/badge.svg)](https://github.com/ballerina-platform/module-ballerinax-ibm.ibmmq/actions/workflows/trivy-scan.yml) +[![GraalVM Check](https://github.com/ballerina-platform/module-ballerinax-ibm.ibmmq/actions/workflows/build-with-bal-test-graalvm.yml/badge.svg)](https://github.com/ballerina-platform/module-ballerinax-ibm.ibmmq/actions/workflows/build-with-bal-test-graalvm.yml) +[![GitHub Last Commit](https://img.shields.io/github/last-commit/ballerina-platform/module-ballerinax-ibm.ibmmq.svg)](https://github.com/ballerina-platform/module-ballerinax-ibm.ibmmq/commits/main) + +The `ballerinax/ibm.ibmmq` library provides an API to connect to an IBM MQ server using Ballerina. + +This library is created with minimal deviation from the IBM MQ java client API to make it easy for the developers who are used to working with the IBM MQ java client API. + +## 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](https://github.com/ballerina-platform/ballerina-standard-library). + +This repository only contains the source code for the library. + +## Build from the source + +### Set up the prerequisites + +* Download and install Java SE Development Kit (JDK) version 17 (from one of the following locations). + + * [Oracle](https://www.oracle.com/java/technologies/downloads/) + + * [OpenJDK](https://adoptium.net/) + + > **Note:** Set the JAVA_HOME environment variable to the path name of the directory into which you installed JDK. + +2. Download and install [Docker](https://www.docker.com/). 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= + ``` +5. To debug the library with Ballerina language: + ``` + ./gradlew clean build -PbalJavaDebug= + ``` +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](https://github.com/ballerina-platform/ballerina-lang/blob/master/CONTRIBUTING.md). + +## Code of conduct + +All the contributors are encouraged to read the [Ballerina Code of Conduct](https://ballerina.io/code-of-conduct). + +## Useful links + +* For more information go to the [`ibm.ibmmq` library](https://lib.ballerina.io/ballerinax/ibm.ibmmq/latest). +* For example demonstrations of the usage, go to [Ballerina By Examples](https://ballerina.io/learn/by-example/). +* Chat live with us via our [Discord server](https://discord.gg/ballerinalang). +* Post all technical questions on Stack Overflow with the [#ballerina](https://stackoverflow.com/questions/tagged/ballerina) tag. From 507f67c6c45862ecb541d89f951b233173774d55 Mon Sep 17 00:00:00 2001 From: ayeshLK Date: Mon, 30 Oct 2023 15:04:40 +0530 Subject: [PATCH 6/8] Update package documentation --- README.md | 9 ++++++++- ballerina/Module.md | 14 ++++++++++++++ ballerina/Package.md | 14 ++++++++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 ballerina/Module.md create mode 100644 ballerina/Package.md diff --git a/README.md b/README.md index 2e85f18..de182f1 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,14 @@ The `ballerinax/ibm.ibmmq` library provides an API to connect to an IBM MQ server using Ballerina. -This library is created with minimal deviation from the IBM MQ java client API to make it easy for the developers who are used to working with the IBM MQ java client API. +This library is created with minimal deviation from the IBM MQ java client API to make it easy for the developers who are used to working with the IBM MQ java client. + +Currently, the following IBM MQ API Classes are supported through this package. + +- QueueManager +- Queue +- Destination (Queue, Topic) +- Message ## Issues and projects diff --git a/ballerina/Module.md b/ballerina/Module.md new file mode 100644 index 0000000..0a416b0 --- /dev/null +++ b/ballerina/Module.md @@ -0,0 +1,14 @@ +## Overview + +The `ballerinax/ibm.ibmmq` module provides an API to connect to an IBM MQ server using Ballerina. + +This module is created with minimal deviation from the IBM MQ java client API to make it easy for the developers who are used to working with the IBM MQ java client. + +Currently, the following IBM MQ API Classes are supported through this package. + +- QueueManager +- Queue +- Destination (Queue, Topic) +- Message + +## Samples diff --git a/ballerina/Package.md b/ballerina/Package.md new file mode 100644 index 0000000..b7175e8 --- /dev/null +++ b/ballerina/Package.md @@ -0,0 +1,14 @@ +## Package overview + +The `ballerinax/ibm.ibmmq` package provides an API to connect to an IBM MQ server using Ballerina. + +This package is created with minimal deviation from the IBM MQ java client API to make it easy for the developers who are used to working with the IBM MQ java client. + +Currently, the following IBM MQ API Classes are supported through this package. + +- QueueManager +- Queue +- Destination (Queue, Topic) +- Message + +## Samples From 8f1f8b03de8f011cf9ed73429ab96774ebc85d1b Mon Sep 17 00:00:00 2001 From: ayeshLK Date: Mon, 30 Oct 2023 16:20:23 +0530 Subject: [PATCH 7/8] Fix logic issue in saving native-queue in the bobject --- .../src/main/java/io/ballerina/lib/ibm.ibmmq/QueueManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/native/src/main/java/io/ballerina/lib/ibm.ibmmq/QueueManager.java b/native/src/main/java/io/ballerina/lib/ibm.ibmmq/QueueManager.java index 85a4780..846b102 100644 --- a/native/src/main/java/io/ballerina/lib/ibm.ibmmq/QueueManager.java +++ b/native/src/main/java/io/ballerina/lib/ibm.ibmmq/QueueManager.java @@ -89,7 +89,7 @@ public static Object accessQueue(BObject queueManagerObject, BString queueName, try { MQQueue mqQueue = queueManager.accessQueue(queueName.getValue(), options.intValue()); BObject bQueue = ValueCreator.createObjectValue(ModuleUtils.getModule(), BQUEUE); - bQueue.addNativeData(Constants.NATIVE_TOPIC, mqQueue); + bQueue.addNativeData(Constants.NATIVE_QUEUE, mqQueue); return bQueue; } catch (MQException e) { return createError(IBMMQ_ERROR, From d3ba51763e29ad93627131afb541d17539b784d7 Mon Sep 17 00:00:00 2001 From: ayeshLK Date: Tue, 31 Oct 2023 10:50:06 +0530 Subject: [PATCH 8/8] Refactor according to the review comments --- ballerina/destination.bal | 10 ++++++++-- ballerina/types.bal | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ballerina/destination.bal b/ballerina/destination.bal index 12afd8c..43b31b2 100644 --- a/ballerina/destination.bal +++ b/ballerina/destination.bal @@ -41,13 +41,16 @@ public isolated client class Queue { # Retrieves a message from an IBM MQ queue. # # + getMessageOptions - Options to control message retrieval - # + return - An `ibmmq:Message` if there is any message in the queue, `()` if there + # + return - An `ibmmq:Message` if there is a message in the queue, `()` if there # is no message or else `ibmmq:Error` if the operation fails remote function get(*GetMessageOptions getMessageOptions) returns Message|Error? = @java:Method { 'class: "io.ballerina.lib.ibm.ibmmq.Queue" } external; + # Closes the IBM MQ queue object. No further operations on this object are permitted after it is closed. + # + # + return - An `ibmmq:Error` if the operation fails or else `()` remote function close() returns Error? = @java:Method { 'class: "io.ballerina.lib.ibm.ibmmq.Queue" @@ -70,13 +73,16 @@ public isolated client class Topic { # Retrieves a message from an IBM MQ topic. # # + getMessageOptions - Options to control message retrieval - # + return - An `ibmmq:Message` if there is any message in the queue, `()` if there + # + return - An `ibmmq:Message` if there is a message in the topic, `()` if there # is no message or else `ibmmq:Error` if the operation fails remote function get(*GetMessageOptions getMessageOptions) returns Message|Error? = @java:Method { 'class: "io.ballerina.lib.ibm.ibmmq.Topic" } external; + # Closes the IBM MQ topic object. No further operations on this object are permitted after it is closed. + # + # + return - An `ibmmq:Error` if the operation fails or else `()` remote function close() returns Error? = @java:Method { 'class: "io.ballerina.lib.ibm.ibmmq.Topic" diff --git a/ballerina/types.bal b/ballerina/types.bal index d8357a3..465e248 100644 --- a/ballerina/types.bal +++ b/ballerina/types.bal @@ -37,7 +37,7 @@ public type QueueManagerConfiguration record {| # IBM MQ get message options. # # + options - Get message option -# + waitInterval - The maximum time (in seconds) that an `get` call waits for a suitable message to +# + waitInterval - The maximum time (in seconds) that a `get` call waits for a suitable message to # arrive. It is used in conjunction with `ibmmq.MQGMO_WAIT`. public type GetMessageOptions record {| int options = MQGMO_NO_WAIT;