From 5151afbb8cbc77cffbc584f6451dff27fc149ef6 Mon Sep 17 00:00:00 2001 From: ayeshLK Date: Wed, 4 Sep 2024 23:47:41 +0530 Subject: [PATCH] Introduce native support to pass MQPutMessageOptions --- .../src/main/java/io/ballerina/lib/ibm.ibmmq/Queue.java | 8 ++++++-- .../src/main/java/io/ballerina/lib/ibm.ibmmq/Topic.java | 7 +++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/native/src/main/java/io/ballerina/lib/ibm.ibmmq/Queue.java b/native/src/main/java/io/ballerina/lib/ibm.ibmmq/Queue.java index 5b314ed..b9d98e7 100644 --- a/native/src/main/java/io/ballerina/lib/ibm.ibmmq/Queue.java +++ b/native/src/main/java/io/ballerina/lib/ibm.ibmmq/Queue.java @@ -21,6 +21,7 @@ import com.ibm.mq.MQException; import com.ibm.mq.MQGetMessageOptions; import com.ibm.mq.MQMessage; +import com.ibm.mq.MQPutMessageOptions; import com.ibm.mq.MQQueue; import com.ibm.mq.constants.CMQC; import io.ballerina.lib.ibm.ibmmq.config.GetMessageOptions; @@ -44,13 +45,16 @@ public class Queue { private static final ExecutorService QUEUE_EXECUTOR_SERVICE = Executors.newCachedThreadPool( new MQThreadFactory("balx-ibmmq-queue-client-network-thread")); - public static Object put(Environment environment, BObject queueObject, BMap message) { + public static Object put(Environment environment, BObject queueObject, BMap message, + long options) { MQQueue queue = (MQQueue) queueObject.getNativeData(Constants.NATIVE_QUEUE); MQMessage mqMessage = CommonUtils.getMqMessageFromBMessage(message); Future future = environment.markAsync(); QUEUE_EXECUTOR_SERVICE.execute(() -> { try { - queue.put(mqMessage); + MQPutMessageOptions pmo = new MQPutMessageOptions(); + pmo.options = (int) options; + queue.put(mqMessage, pmo); future.complete(null); } catch (MQException e) { BError bError = createError(IBMMQ_ERROR, diff --git a/native/src/main/java/io/ballerina/lib/ibm.ibmmq/Topic.java b/native/src/main/java/io/ballerina/lib/ibm.ibmmq/Topic.java index 1d5611d..b5c802f 100644 --- a/native/src/main/java/io/ballerina/lib/ibm.ibmmq/Topic.java +++ b/native/src/main/java/io/ballerina/lib/ibm.ibmmq/Topic.java @@ -21,6 +21,7 @@ import com.ibm.mq.MQException; import com.ibm.mq.MQGetMessageOptions; import com.ibm.mq.MQMessage; +import com.ibm.mq.MQPutMessageOptions; import com.ibm.mq.MQTopic; import com.ibm.mq.constants.CMQC; import io.ballerina.lib.ibm.ibmmq.config.GetMessageOptions; @@ -44,13 +45,15 @@ public class Topic { private static final ExecutorService topicExecutorService = Executors.newCachedThreadPool( new MQThreadFactory("balx-ibmmq-topic-client-network-thread")); - public static Object put(Environment environment, BObject topicObject, BMap message) { + public static Object put(Environment environment, BObject topicObject, BMap message, long options) { MQTopic topic = (MQTopic) topicObject.getNativeData(Constants.NATIVE_TOPIC); MQMessage mqMessage = CommonUtils.getMqMessageFromBMessage(message); Future future = environment.markAsync(); topicExecutorService.execute(() -> { try { - topic.put(mqMessage); + MQPutMessageOptions pmo = new MQPutMessageOptions(); + pmo.options = (int) options; + topic.put(mqMessage, pmo); future.complete(null); } catch (Exception e) { BError bError = createError(IBMMQ_ERROR,