From 4c9b89e17b8a9e956d4236bf004d1fc2f3024c00 Mon Sep 17 00:00:00 2001 From: ayeshLK Date: Mon, 26 Feb 2024 10:22:12 +0530 Subject: [PATCH 01/14] Add example for message producing --- examples/produce-messages/.github/README.md | 1 + examples/produce-messages/Ballerina.toml | 8 ++++ examples/produce-messages/Config.toml | 7 ++++ examples/produce-messages/Produce Messages.md | 31 ++++++++++++++ examples/produce-messages/main.bal | 41 +++++++++++++++++++ 5 files changed, 88 insertions(+) create mode 100644 examples/produce-messages/.github/README.md create mode 100644 examples/produce-messages/Ballerina.toml create mode 100644 examples/produce-messages/Config.toml create mode 100644 examples/produce-messages/Produce Messages.md create mode 100644 examples/produce-messages/main.bal diff --git a/examples/produce-messages/.github/README.md b/examples/produce-messages/.github/README.md new file mode 100644 index 0000000..1325311 --- /dev/null +++ b/examples/produce-messages/.github/README.md @@ -0,0 +1 @@ +../Produce Messages.md \ No newline at end of file diff --git a/examples/produce-messages/Ballerina.toml b/examples/produce-messages/Ballerina.toml new file mode 100644 index 0000000..29348d0 --- /dev/null +++ b/examples/produce-messages/Ballerina.toml @@ -0,0 +1,8 @@ +[package] +org = "wso2" +name = "produce_messages" +version = "0.1.0" +distribution = "2201.8.4" + +[build-options] +observabilityIncluded = true diff --git a/examples/produce-messages/Config.toml b/examples/produce-messages/Config.toml new file mode 100644 index 0000000..aa26aaf --- /dev/null +++ b/examples/produce-messages/Config.toml @@ -0,0 +1,7 @@ +queueManagerName = "QM1" +host = "localhost" +port = 1414 +channel = "DEV.APP.SVRCONN" +userID = "app" +password = "password" +queueName = "DEV.QUEUE.1" diff --git a/examples/produce-messages/Produce Messages.md b/examples/produce-messages/Produce Messages.md new file mode 100644 index 0000000..37449f9 --- /dev/null +++ b/examples/produce-messages/Produce Messages.md @@ -0,0 +1,31 @@ +# Produce messages + +This example demonstrates how to produce messages to an IBM MQ queue. + +## Prerequisites + +### 1. Setup Gmail API + +Refer to the [Setup Guide](https://dev-central.ballerina.io/ballerinax/ibm.ibmmq/latest#setup-guide) to set up the IBM MQ server locally. + +### 2. Configuration + +Configure Gmail API credentials in `Config.toml` in the example directory: + +```toml +queueManagerName = "" +host = "" +port = +channel = "" +userID = "" +password = "" +queueName = "" +``` + +## Run the Example + +Execute the following command to run the example: + +```bash +bal run +``` diff --git a/examples/produce-messages/main.bal b/examples/produce-messages/main.bal new file mode 100644 index 0000000..05716bc --- /dev/null +++ b/examples/produce-messages/main.bal @@ -0,0 +1,41 @@ +// Copyright (c) 2024, WSO2 LLC. (http://www.wso2.org). +// +// WSO2 LLC. licenses this file to you under the Apache License, +// Version 2.0 (the "License"); you may not use this file except +// in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +import ballerinax/ibm.ibmmq; + +configurable string queueManagerName = ?; +configurable string host = ?; +configurable int port = ?; +configurable string channel = ?; +configurable string userID = ?; +configurable string password = ?; +configurable string queueName = ?; + +public function main() returns error?{ + ibmmq:QueueManager queueManager = check new ( + name = queueManagerName, + host = host, + channel = channel, + userID = userID, + password = password + ); + ibmmq:Queue queue = check queueManager.accessQueue(queueName, ibmmq:MQOO_OUTPUT); + check queue->put({ + payload: "This is a sample message to IBM MQ queue".toBytes() + }); + check queue->close(); + check queueManager.disconnect(); +} From a030e95e521bd29450969be18cea659512942e98 Mon Sep 17 00:00:00 2001 From: ayeshLK Date: Mon, 26 Feb 2024 10:27:18 +0530 Subject: [PATCH 02/14] Update the readme --- examples/produce-messages/Produce Messages.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/produce-messages/Produce Messages.md b/examples/produce-messages/Produce Messages.md index 37449f9..90ded7f 100644 --- a/examples/produce-messages/Produce Messages.md +++ b/examples/produce-messages/Produce Messages.md @@ -4,13 +4,13 @@ This example demonstrates how to produce messages to an IBM MQ queue. ## Prerequisites -### 1. Setup Gmail API +### 1. Setup IBM MQ server Refer to the [Setup Guide](https://dev-central.ballerina.io/ballerinax/ibm.ibmmq/latest#setup-guide) to set up the IBM MQ server locally. ### 2. Configuration -Configure Gmail API credentials in `Config.toml` in the example directory: +Update IBM MQ related configurations in `Config.toml` in the example directory: ```toml queueManagerName = "" From f05d36bb44eecc8aa75029322e5de9583d12c40e Mon Sep 17 00:00:00 2001 From: ayeshLK Date: Mon, 26 Feb 2024 10:35:53 +0530 Subject: [PATCH 03/14] Add README.md file --- examples/produce-messages/.github/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 120000 examples/produce-messages/.github/README.md diff --git a/examples/produce-messages/.github/README.md b/examples/produce-messages/.github/README.md deleted file mode 100644 index 1325311..0000000 --- a/examples/produce-messages/.github/README.md +++ /dev/null @@ -1 +0,0 @@ -../Produce Messages.md \ No newline at end of file diff --git a/examples/produce-messages/.github/README.md b/examples/produce-messages/.github/README.md new file mode 120000 index 0000000..092fb3c --- /dev/null +++ b/examples/produce-messages/.github/README.md @@ -0,0 +1 @@ +Produce Messages.md \ No newline at end of file From 8573f7978d96781cd2050f5d9e7fd56d55992953 Mon Sep 17 00:00:00 2001 From: ayeshLK Date: Mon, 26 Feb 2024 10:38:21 +0530 Subject: [PATCH 04/14] Add README.md file --- examples/produce-messages/.github/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/produce-messages/.github/README.md b/examples/produce-messages/.github/README.md index 092fb3c..7fa2922 120000 --- a/examples/produce-messages/.github/README.md +++ b/examples/produce-messages/.github/README.md @@ -1 +1 @@ -Produce Messages.md \ No newline at end of file +./Produce Messages.md \ No newline at end of file From 6d364a555ce8407340aed753cc2b42fab41f1134 Mon Sep 17 00:00:00 2001 From: ayeshLK Date: Mon, 26 Feb 2024 10:48:41 +0530 Subject: [PATCH 05/14] Add symlink to the readme --- examples/produce-messages/.github/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/produce-messages/.github/README.md b/examples/produce-messages/.github/README.md index 7fa2922..1325311 120000 --- a/examples/produce-messages/.github/README.md +++ b/examples/produce-messages/.github/README.md @@ -1 +1 @@ -./Produce Messages.md \ No newline at end of file +../Produce Messages.md \ No newline at end of file From f3caca9218ce4226d7ac2ba9cefe888f7ab5a021 Mon Sep 17 00:00:00 2001 From: ayeshLK Date: Mon, 26 Feb 2024 10:58:27 +0530 Subject: [PATCH 06/14] Update ballerina toml configurations --- examples/produce-messages/Ballerina.toml | 3 --- 1 file changed, 3 deletions(-) diff --git a/examples/produce-messages/Ballerina.toml b/examples/produce-messages/Ballerina.toml index 29348d0..424bcb6 100644 --- a/examples/produce-messages/Ballerina.toml +++ b/examples/produce-messages/Ballerina.toml @@ -3,6 +3,3 @@ org = "wso2" name = "produce_messages" version = "0.1.0" distribution = "2201.8.4" - -[build-options] -observabilityIncluded = true From 1b9ec56dc8231d105a308b1eac527bf1e57f4b20 Mon Sep 17 00:00:00 2001 From: ayeshLK Date: Mon, 26 Feb 2024 10:58:47 +0530 Subject: [PATCH 07/14] Add consume-messages example --- examples/consume-messages/.github/README.md | 1 + examples/consume-messages/Ballerina.toml | 5 +++ examples/consume-messages/Config.toml | 7 +++ examples/consume-messages/Consume Messages.md | 31 +++++++++++++ examples/consume-messages/main.bal | 44 +++++++++++++++++++ 5 files changed, 88 insertions(+) create mode 120000 examples/consume-messages/.github/README.md create mode 100644 examples/consume-messages/Ballerina.toml create mode 100644 examples/consume-messages/Config.toml create mode 100644 examples/consume-messages/Consume Messages.md create mode 100644 examples/consume-messages/main.bal diff --git a/examples/consume-messages/.github/README.md b/examples/consume-messages/.github/README.md new file mode 120000 index 0000000..b2c3ba1 --- /dev/null +++ b/examples/consume-messages/.github/README.md @@ -0,0 +1 @@ +../Consume Messages.md \ No newline at end of file diff --git a/examples/consume-messages/Ballerina.toml b/examples/consume-messages/Ballerina.toml new file mode 100644 index 0000000..d0a28d1 --- /dev/null +++ b/examples/consume-messages/Ballerina.toml @@ -0,0 +1,5 @@ +[package] +org = "wso2" +name = "consume_messages" +version = "0.1.0" +distribution = "2201.8.4" diff --git a/examples/consume-messages/Config.toml b/examples/consume-messages/Config.toml new file mode 100644 index 0000000..aa26aaf --- /dev/null +++ b/examples/consume-messages/Config.toml @@ -0,0 +1,7 @@ +queueManagerName = "QM1" +host = "localhost" +port = 1414 +channel = "DEV.APP.SVRCONN" +userID = "app" +password = "password" +queueName = "DEV.QUEUE.1" diff --git a/examples/consume-messages/Consume Messages.md b/examples/consume-messages/Consume Messages.md new file mode 100644 index 0000000..2cf0c7b --- /dev/null +++ b/examples/consume-messages/Consume Messages.md @@ -0,0 +1,31 @@ +# Consume messages + +This example demonstrates how to consume messages from an IBM MQ queue. + +## Prerequisites + +### 1. Setup IBM MQ server + +Refer to the [Setup Guide](https://dev-central.ballerina.io/ballerinax/ibm.ibmmq/latest#setup-guide) to set up the IBM MQ server locally. + +### 2. Configuration + +Update IBM MQ related configurations in `Config.toml` in the example directory: + +```toml +queueManagerName = "" +host = "" +port = +channel = "" +userID = "" +password = "" +queueName = "" +``` + +## Run the Example + +Execute the following command to run the example: + +```bash +bal run +``` diff --git a/examples/consume-messages/main.bal b/examples/consume-messages/main.bal new file mode 100644 index 0000000..f625c17 --- /dev/null +++ b/examples/consume-messages/main.bal @@ -0,0 +1,44 @@ +// Copyright (c) 2024, WSO2 LLC. (http://www.wso2.org). +// +// WSO2 LLC. licenses this file to you under the Apache License, +// Version 2.0 (the "License"); you may not use this file except +// in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +import ballerinax/ibm.ibmmq; +import ballerina/io; + +configurable string queueManagerName = ?; +configurable string host = ?; +configurable int port = ?; +configurable string channel = ?; +configurable string userID = ?; +configurable string password = ?; +configurable string queueName = ?; + +public function main() returns error? { + ibmmq:QueueManager queueManager = check new ( + name = queueManagerName, + host = host, + channel = channel, + userID = userID, + password = password + ); + ibmmq:Queue queue = check queueManager.accessQueue(queueName, ibmmq:MQOO_INPUT_AS_Q_DEF); + ibmmq:Message? message = check queue->get(options = ibmmq:MQGMO_WAIT); + while true { + if message is () { + continue; + } + io:println(string:fromBytes(message.payload)); + } +} From e63550c6e3530ce6b99db45f56937481e24635b6 Mon Sep 17 00:00:00 2001 From: ayeshLK Date: Mon, 26 Feb 2024 11:12:55 +0530 Subject: [PATCH 08/14] Restructure IBM MQ client security related example --- .../ibmmq-client-security/.github/README.md | 1 + examples/ibmmq-client-security/Config.toml | 7 +++++ .../Securing IBM MQ Client.md | 31 +++++++++++++++++++ examples/ibmmq-client-security/main.bal | 23 +++++++++----- 4 files changed, 55 insertions(+), 7 deletions(-) create mode 120000 examples/ibmmq-client-security/.github/README.md create mode 100644 examples/ibmmq-client-security/Config.toml create mode 100644 examples/ibmmq-client-security/Securing IBM MQ Client.md diff --git a/examples/ibmmq-client-security/.github/README.md b/examples/ibmmq-client-security/.github/README.md new file mode 120000 index 0000000..d556e9b --- /dev/null +++ b/examples/ibmmq-client-security/.github/README.md @@ -0,0 +1 @@ +../Securing IBM MQ Client.md \ No newline at end of file diff --git a/examples/ibmmq-client-security/Config.toml b/examples/ibmmq-client-security/Config.toml new file mode 100644 index 0000000..aa26aaf --- /dev/null +++ b/examples/ibmmq-client-security/Config.toml @@ -0,0 +1,7 @@ +queueManagerName = "QM1" +host = "localhost" +port = 1414 +channel = "DEV.APP.SVRCONN" +userID = "app" +password = "password" +queueName = "DEV.QUEUE.1" diff --git a/examples/ibmmq-client-security/Securing IBM MQ Client.md b/examples/ibmmq-client-security/Securing IBM MQ Client.md new file mode 100644 index 0000000..37bd033 --- /dev/null +++ b/examples/ibmmq-client-security/Securing IBM MQ Client.md @@ -0,0 +1,31 @@ +# Securing IBM MQ client + +This example demonstrates how to initiate secure communication between an IBM MQ client and an IBM MQ server. + +## Prerequisites + +### 1. Setup IBM MQ server + +Refer to the [Setup Guide](https://dev-central.ballerina.io/ballerinax/ibm.ibmmq/latest#setup-guide) to set up the IBM MQ server locally. + +### 2. Configuration + +Update IBM MQ related configurations in `Config.toml` in the example directory: + +```toml +queueManagerName = "" +host = "" +port = +channel = "" +userID = "" +password = "" +queueName = "" +``` + +## Run the Example + +Execute the following command to run the example: + +```bash +bal run +``` diff --git a/examples/ibmmq-client-security/main.bal b/examples/ibmmq-client-security/main.bal index 1041f63..7561e23 100644 --- a/examples/ibmmq-client-security/main.bal +++ b/examples/ibmmq-client-security/main.bal @@ -16,12 +16,21 @@ import ballerinax/ibm.ibmmq; +configurable string queueManagerName = ?; +configurable string host = ?; +configurable int port = ?; +configurable string channel = ?; +configurable string userID = ?; +configurable string password = ?; +configurable string queueName = ?; + public function main() returns error? { ibmmq:QueueManager queueManager = check new ( - name = "QM1", - host = "localhost", - port = 1415, - channel = "DEV.APP.SVRCONN", + name = queueManagerName, + host = host, + channel = channel, + userID = userID, + password = password, // Provide the relevant SSL cipher-suite. sslCipherSuite = ibmmq:TLS12ORHIGHER, secureSocket = { @@ -37,10 +46,10 @@ public function main() returns error? { } } ); - ibmmq:Queue producer = check queueManager.accessQueue("DEV.QUEUE.1", ibmmq:MQOO_OUTPUT); - check producer->put({ + ibmmq:Queue queue = check queueManager.accessQueue(queueName, ibmmq:MQOO_OUTPUT); + check queue->put({ payload: "This is a sample message to IBM MQ queue".toBytes() }); - check producer->close(); + check queue->close(); check queueManager.disconnect(); } From cce8591fa0e3e44350470e1418f277113a8264f7 Mon Sep 17 00:00:00 2001 From: ayeshLK Date: Mon, 26 Feb 2024 11:40:59 +0530 Subject: [PATCH 09/14] Restructure MQIIH headers sample --- .../produce-mqiih-headers/.github/README.md | 1 + .../Ballerina.toml | 0 examples/produce-mqiih-headers/Config.toml | 7 +++++ .../Produce MQIIH Headers.md | 31 +++++++++++++++++++ .../main.bal | 22 ++++++++++--- 5 files changed, 56 insertions(+), 5 deletions(-) create mode 120000 examples/produce-mqiih-headers/.github/README.md rename examples/{send-mqiih-headers => produce-mqiih-headers}/Ballerina.toml (100%) create mode 100644 examples/produce-mqiih-headers/Config.toml create mode 100644 examples/produce-mqiih-headers/Produce MQIIH Headers.md rename examples/{send-mqiih-headers => produce-mqiih-headers}/main.bal (68%) diff --git a/examples/produce-mqiih-headers/.github/README.md b/examples/produce-mqiih-headers/.github/README.md new file mode 120000 index 0000000..ecda81b --- /dev/null +++ b/examples/produce-mqiih-headers/.github/README.md @@ -0,0 +1 @@ +../Produce MQIIH Headers.md \ No newline at end of file diff --git a/examples/send-mqiih-headers/Ballerina.toml b/examples/produce-mqiih-headers/Ballerina.toml similarity index 100% rename from examples/send-mqiih-headers/Ballerina.toml rename to examples/produce-mqiih-headers/Ballerina.toml diff --git a/examples/produce-mqiih-headers/Config.toml b/examples/produce-mqiih-headers/Config.toml new file mode 100644 index 0000000..aa26aaf --- /dev/null +++ b/examples/produce-mqiih-headers/Config.toml @@ -0,0 +1,7 @@ +queueManagerName = "QM1" +host = "localhost" +port = 1414 +channel = "DEV.APP.SVRCONN" +userID = "app" +password = "password" +queueName = "DEV.QUEUE.1" diff --git a/examples/produce-mqiih-headers/Produce MQIIH Headers.md b/examples/produce-mqiih-headers/Produce MQIIH Headers.md new file mode 100644 index 0000000..f9e61d0 --- /dev/null +++ b/examples/produce-mqiih-headers/Produce MQIIH Headers.md @@ -0,0 +1,31 @@ +# Produce MQIIH headers + +This example demonstrates how to produce IBM MQ messages to an IBM MQ queue with MQIIH headers. + +## Prerequisites + +### 1. Setup IBM MQ server + +Refer to the [Setup Guide](https://dev-central.ballerina.io/ballerinax/ibm.ibmmq/latest#setup-guide) to set up the IBM MQ server locally. + +### 2. Configuration + +Update IBM MQ related configurations in `Config.toml` in the example directory: + +```toml +queueManagerName = "" +host = "" +port = +channel = "" +userID = "" +password = "" +queueName = "" +``` + +## Run the Example + +Execute the following command to run the example: + +```bash +bal run +``` diff --git a/examples/send-mqiih-headers/main.bal b/examples/produce-mqiih-headers/main.bal similarity index 68% rename from examples/send-mqiih-headers/main.bal rename to examples/produce-mqiih-headers/main.bal index 606b153..4cbb739 100644 --- a/examples/send-mqiih-headers/main.bal +++ b/examples/produce-mqiih-headers/main.bal @@ -1,4 +1,4 @@ -// Copyright (c) 2023, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. +// Copyright (c) 2024, WSO2 LLC. (http://www.wso2.org). // // WSO2 LLC. licenses this file to you under the Apache License, // Version 2.0 (the "License"); you may not use this file except @@ -16,11 +16,23 @@ import ballerinax/ibm.ibmmq; +configurable string queueManagerName = ?; +configurable string host = ?; +configurable int port = ?; +configurable string channel = ?; +configurable string userID = ?; +configurable string password = ?; +configurable string queueName = ?; + public function main() returns error? { ibmmq:QueueManager queueManager = check new ( - name = "QM1", host = "localhost", channel = "DEV.APP.SVRCONN" + name = queueManagerName, + host = host, + channel = channel, + userID = userID, + password = password ); - ibmmq:Queue producer = check queueManager.accessQueue("DEV.QUEUE.1", ibmmq:MQOO_OUTPUT); + ibmmq:Queue queue = check queueManager.accessQueue(queueName, ibmmq:MQOO_OUTPUT); ibmmq:MQIIH mqiihHeader = { flags: 12, @@ -34,10 +46,10 @@ public function main() returns error? { securityScope: "s" }; - check producer->put({ + check queue->put({ headers: [mqiihHeader], payload: "This is a sample message to IBM MQ queue".toBytes() }); - check producer->close(); + check queue->close(); check queueManager.disconnect(); } From f4f9da108b2cdafff64386ff6d82300d2fa89385 Mon Sep 17 00:00:00 2001 From: ayeshLK Date: Mon, 26 Feb 2024 11:44:11 +0530 Subject: [PATCH 10/14] Update ballerina toml --- examples/produce-mqiih-headers/Ballerina.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/produce-mqiih-headers/Ballerina.toml b/examples/produce-mqiih-headers/Ballerina.toml index eda5bc5..6d2a484 100644 --- a/examples/produce-mqiih-headers/Ballerina.toml +++ b/examples/produce-mqiih-headers/Ballerina.toml @@ -1,6 +1,6 @@ [package] org = "wso2" -name = "send_mq_headers" +name = "produce_mqiih_headers" version = "0.1.0" distribution = "2201.8.2" From a063d9a32d2d7fd7b6716b38284ad95f151c0787 Mon Sep 17 00:00:00 2001 From: ayeshLK Date: Mon, 26 Feb 2024 11:47:11 +0530 Subject: [PATCH 11/14] Restructure MQRFH2 headers sample --- .../produce-mqrfh2-headers/.github/README.md | 1 + .../Ballerina.toml | 2 +- examples/produce-mqrfh2-headers/Config.toml | 7 +++++ .../Produce MQRFH2 Headers.md | 31 +++++++++++++++++++ .../main.bal | 22 ++++++++++--- 5 files changed, 57 insertions(+), 6 deletions(-) create mode 120000 examples/produce-mqrfh2-headers/.github/README.md rename examples/{send-mqrfh2-headers => produce-mqrfh2-headers}/Ballerina.toml (77%) create mode 100644 examples/produce-mqrfh2-headers/Config.toml create mode 100644 examples/produce-mqrfh2-headers/Produce MQRFH2 Headers.md rename examples/{send-mqrfh2-headers => produce-mqrfh2-headers}/main.bal (67%) diff --git a/examples/produce-mqrfh2-headers/.github/README.md b/examples/produce-mqrfh2-headers/.github/README.md new file mode 120000 index 0000000..143e08e --- /dev/null +++ b/examples/produce-mqrfh2-headers/.github/README.md @@ -0,0 +1 @@ +../Produce MQRFH2 Headers.md \ No newline at end of file diff --git a/examples/send-mqrfh2-headers/Ballerina.toml b/examples/produce-mqrfh2-headers/Ballerina.toml similarity index 77% rename from examples/send-mqrfh2-headers/Ballerina.toml rename to examples/produce-mqrfh2-headers/Ballerina.toml index 29dfcb0..232cdd6 100644 --- a/examples/send-mqrfh2-headers/Ballerina.toml +++ b/examples/produce-mqrfh2-headers/Ballerina.toml @@ -1,6 +1,6 @@ [package] org = "wso2" -name = "send_mqrfh2_headers" +name = "produce_mqrfh2_headers" version = "0.1.0" distribution = "2201.8.2" diff --git a/examples/produce-mqrfh2-headers/Config.toml b/examples/produce-mqrfh2-headers/Config.toml new file mode 100644 index 0000000..aa26aaf --- /dev/null +++ b/examples/produce-mqrfh2-headers/Config.toml @@ -0,0 +1,7 @@ +queueManagerName = "QM1" +host = "localhost" +port = 1414 +channel = "DEV.APP.SVRCONN" +userID = "app" +password = "password" +queueName = "DEV.QUEUE.1" diff --git a/examples/produce-mqrfh2-headers/Produce MQRFH2 Headers.md b/examples/produce-mqrfh2-headers/Produce MQRFH2 Headers.md new file mode 100644 index 0000000..529845b --- /dev/null +++ b/examples/produce-mqrfh2-headers/Produce MQRFH2 Headers.md @@ -0,0 +1,31 @@ +# Produce MQRFH2 headers + +This example demonstrates how to produce IBM MQ messages to an IBM MQ queue with MQRFH2 headers. + +## Prerequisites + +### 1. Setup IBM MQ server + +Refer to the [Setup Guide](https://dev-central.ballerina.io/ballerinax/ibm.ibmmq/latest#setup-guide) to set up the IBM MQ server locally. + +### 2. Configuration + +Update IBM MQ related configurations in `Config.toml` in the example directory: + +```toml +queueManagerName = "" +host = "" +port = +channel = "" +userID = "" +password = "" +queueName = "" +``` + +## Run the Example + +Execute the following command to run the example: + +```bash +bal run +``` diff --git a/examples/send-mqrfh2-headers/main.bal b/examples/produce-mqrfh2-headers/main.bal similarity index 67% rename from examples/send-mqrfh2-headers/main.bal rename to examples/produce-mqrfh2-headers/main.bal index fee0e02..507078f 100644 --- a/examples/send-mqrfh2-headers/main.bal +++ b/examples/produce-mqrfh2-headers/main.bal @@ -1,4 +1,4 @@ -// Copyright (c) 2023, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. +// Copyright (c) 2024, WSO2 LLC. (http://www.wso2.org). // // WSO2 LLC. licenses this file to you under the Apache License, // Version 2.0 (the "License"); you may not use this file except @@ -16,11 +16,23 @@ import ballerinax/ibm.ibmmq; +configurable string queueManagerName = ?; +configurable string host = ?; +configurable int port = ?; +configurable string channel = ?; +configurable string userID = ?; +configurable string password = ?; +configurable string queueName = ?; + public function main() returns error? { ibmmq:QueueManager queueManager = check new ( - name = "QM1", host = "localhost", channel = "DEV.APP.SVRCONN" + name = queueManagerName, + host = host, + channel = channel, + userID = userID, + password = password ); - ibmmq:Queue producer = check queueManager.accessQueue("DEV.QUEUE.1", ibmmq:MQOO_OUTPUT); + ibmmq:Queue queue = check queueManager.accessQueue(queueName, ibmmq:MQOO_OUTPUT); ibmmq:MQRFH2 mqrfh2Header = { flags: 12, @@ -31,10 +43,10 @@ public function main() returns error? { ] }; - check producer->put({ + check queue->put({ headers: [mqrfh2Header], payload: "This is a sample message to IBM MQ queue".toBytes() }); - check producer->close(); + check queue->close(); check queueManager.disconnect(); } From 585386eb23ef2de2f7649b584d93d5fffbd5cb7c Mon Sep 17 00:00:00 2001 From: ayeshLK Date: Mon, 26 Feb 2024 11:51:11 +0530 Subject: [PATCH 12/14] Restructure MQIIH header consuming example --- .../consume-mqiih-headers/.github/README.md | 1 + examples/consume-mqiih-headers/Config.toml | 7 +++++ .../Consume MQIIH Headers.md | 31 +++++++++++++++++++ examples/consume-mqiih-headers/main.bal | 20 +++++++++--- 4 files changed, 55 insertions(+), 4 deletions(-) create mode 120000 examples/consume-mqiih-headers/.github/README.md create mode 100644 examples/consume-mqiih-headers/Config.toml create mode 100644 examples/consume-mqiih-headers/Consume MQIIH Headers.md diff --git a/examples/consume-mqiih-headers/.github/README.md b/examples/consume-mqiih-headers/.github/README.md new file mode 120000 index 0000000..c1ab19a --- /dev/null +++ b/examples/consume-mqiih-headers/.github/README.md @@ -0,0 +1 @@ +../Consume MQIIH Headers.md \ No newline at end of file diff --git a/examples/consume-mqiih-headers/Config.toml b/examples/consume-mqiih-headers/Config.toml new file mode 100644 index 0000000..aa26aaf --- /dev/null +++ b/examples/consume-mqiih-headers/Config.toml @@ -0,0 +1,7 @@ +queueManagerName = "QM1" +host = "localhost" +port = 1414 +channel = "DEV.APP.SVRCONN" +userID = "app" +password = "password" +queueName = "DEV.QUEUE.1" diff --git a/examples/consume-mqiih-headers/Consume MQIIH Headers.md b/examples/consume-mqiih-headers/Consume MQIIH Headers.md new file mode 100644 index 0000000..8e63c80 --- /dev/null +++ b/examples/consume-mqiih-headers/Consume MQIIH Headers.md @@ -0,0 +1,31 @@ +# Consume MQIIH headers + +This example demonstrates how to consume messages with MQIIH header from an IBM MQ queue. + +## Prerequisites + +### 1. Setup IBM MQ server + +Refer to the [Setup Guide](https://dev-central.ballerina.io/ballerinax/ibm.ibmmq/latest#setup-guide) to set up the IBM MQ server locally. + +### 2. Configuration + +Update IBM MQ related configurations in `Config.toml` in the example directory: + +```toml +queueManagerName = "" +host = "" +port = +channel = "" +userID = "" +password = "" +queueName = "" +``` + +## Run the Example + +Execute the following command to run the example: + +```bash +bal run +``` diff --git a/examples/consume-mqiih-headers/main.bal b/examples/consume-mqiih-headers/main.bal index 2dc8482..325f340 100644 --- a/examples/consume-mqiih-headers/main.bal +++ b/examples/consume-mqiih-headers/main.bal @@ -17,14 +17,26 @@ import ballerinax/ibm.ibmmq; import ballerina/io; +configurable string queueManagerName = ?; +configurable string host = ?; +configurable int port = ?; +configurable string channel = ?; +configurable string userID = ?; +configurable string password = ?; +configurable string queueName = ?; + public function main() returns error? { ibmmq:QueueManager queueManager = check new ( - name = "QM1", host = "localhost", channel = "DEV.APP.SVRCONN" + name = queueManagerName, + host = host, + channel = channel, + userID = userID, + password = password ); - ibmmq:Queue consumer = check queueManager.accessQueue( - "DEV.QUEUE.1", ibmmq:MQOO_INPUT_AS_Q_DEF); + ibmmq:Queue queue = check queueManager.accessQueue(queueName, ibmmq:MQOO_INPUT_AS_Q_DEF); + while true { - ibmmq:Message? message = check consumer->get(options = ibmmq:MQGMO_WAIT); + ibmmq:Message? message = check queue->get(options = ibmmq:MQGMO_WAIT); if message is () { continue; } From c5dc2c6f4fbb7ed8e1d9bfd45ba68429af86d299 Mon Sep 17 00:00:00 2001 From: ayeshLK Date: Mon, 26 Feb 2024 11:52:20 +0530 Subject: [PATCH 13/14] Update Ballerina toml file --- examples/consume-mqiih-headers/Ballerina.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/consume-mqiih-headers/Ballerina.toml b/examples/consume-mqiih-headers/Ballerina.toml index 53ff3ad..e513976 100644 --- a/examples/consume-mqiih-headers/Ballerina.toml +++ b/examples/consume-mqiih-headers/Ballerina.toml @@ -1,6 +1,6 @@ [package] org = "wso2" -name = "consume_mqcih_headers" +name = "consume_mqiih_headers" version = "0.1.0" distribution = "2201.8.2" From 37df1ac63e357a4e83b39625344c237cb0f36456 Mon Sep 17 00:00:00 2001 From: ayeshLK Date: Mon, 26 Feb 2024 11:55:04 +0530 Subject: [PATCH 14/14] Restructure MQRFH2 header consuming example --- .../consume-mqrfh2-headers/.github/README.md | 1 + examples/consume-mqrfh2-headers/Config.toml | 7 +++++ .../Consume MQRFH2 Headers.md | 31 +++++++++++++++++++ examples/consume-mqrfh2-headers/main.bal | 20 +++++++++--- 4 files changed, 55 insertions(+), 4 deletions(-) create mode 120000 examples/consume-mqrfh2-headers/.github/README.md create mode 100644 examples/consume-mqrfh2-headers/Config.toml create mode 100644 examples/consume-mqrfh2-headers/Consume MQRFH2 Headers.md diff --git a/examples/consume-mqrfh2-headers/.github/README.md b/examples/consume-mqrfh2-headers/.github/README.md new file mode 120000 index 0000000..7a8d3ce --- /dev/null +++ b/examples/consume-mqrfh2-headers/.github/README.md @@ -0,0 +1 @@ +../Consume MQRFH2 Headers.md \ No newline at end of file diff --git a/examples/consume-mqrfh2-headers/Config.toml b/examples/consume-mqrfh2-headers/Config.toml new file mode 100644 index 0000000..aa26aaf --- /dev/null +++ b/examples/consume-mqrfh2-headers/Config.toml @@ -0,0 +1,7 @@ +queueManagerName = "QM1" +host = "localhost" +port = 1414 +channel = "DEV.APP.SVRCONN" +userID = "app" +password = "password" +queueName = "DEV.QUEUE.1" diff --git a/examples/consume-mqrfh2-headers/Consume MQRFH2 Headers.md b/examples/consume-mqrfh2-headers/Consume MQRFH2 Headers.md new file mode 100644 index 0000000..9d5adc6 --- /dev/null +++ b/examples/consume-mqrfh2-headers/Consume MQRFH2 Headers.md @@ -0,0 +1,31 @@ +# Consume MQRFH2 headers + +This example demonstrates how to consume messages with MQRFH2 header from an IBM MQ queue. + +## Prerequisites + +### 1. Setup IBM MQ server + +Refer to the [Setup Guide](https://dev-central.ballerina.io/ballerinax/ibm.ibmmq/latest#setup-guide) to set up the IBM MQ server locally. + +### 2. Configuration + +Update IBM MQ related configurations in `Config.toml` in the example directory: + +```toml +queueManagerName = "" +host = "" +port = +channel = "" +userID = "" +password = "" +queueName = "" +``` + +## Run the Example + +Execute the following command to run the example: + +```bash +bal run +``` diff --git a/examples/consume-mqrfh2-headers/main.bal b/examples/consume-mqrfh2-headers/main.bal index bbc5e77..bceded4 100644 --- a/examples/consume-mqrfh2-headers/main.bal +++ b/examples/consume-mqrfh2-headers/main.bal @@ -17,14 +17,26 @@ import ballerinax/ibm.ibmmq; import ballerina/io; +configurable string queueManagerName = ?; +configurable string host = ?; +configurable int port = ?; +configurable string channel = ?; +configurable string userID = ?; +configurable string password = ?; +configurable string queueName = ?; + public function main() returns error? { ibmmq:QueueManager queueManager = check new ( - name = "QM1", host = "localhost", channel = "DEV.APP.SVRCONN" + name = queueManagerName, + host = host, + channel = channel, + userID = userID, + password = password ); - ibmmq:Queue consumer = check queueManager.accessQueue( - "DEV.QUEUE.1", ibmmq:MQOO_INPUT_AS_Q_DEF); + ibmmq:Queue queue = check queueManager.accessQueue(queueName, ibmmq:MQOO_INPUT_AS_Q_DEF); + while true { - ibmmq:Message? message = check consumer->get(options = ibmmq:MQGMO_WAIT); + ibmmq:Message? message = check queue->get(options = ibmmq:MQGMO_WAIT); if message is () { continue; }