Skip to content

Commit

Permalink
Update MQMessage to bMsg converstion logic with new fields
Browse files Browse the repository at this point in the history
  • Loading branch information
ayeshLK committed Sep 4, 2024
1 parent 14c79b6 commit 4c01768
Showing 1 changed file with 44 additions and 1 deletion.
45 changes: 44 additions & 1 deletion native/src/main/java/io/ballerina/lib/ibm.ibmmq/CommonUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,42 @@
import java.util.Objects;
import java.util.Optional;

import static io.ballerina.lib.ibm.ibmmq.Constants.*;
import static io.ballerina.lib.ibm.ibmmq.Constants.CORRELATION_ID_FIELD;
import static io.ballerina.lib.ibm.ibmmq.Constants.BPROPERTY;
import static io.ballerina.lib.ibm.ibmmq.Constants.BMESSAGE_NAME;
import static io.ballerina.lib.ibm.ibmmq.Constants.ERROR_COMPLETION_CODE;
import static io.ballerina.lib.ibm.ibmmq.Constants.ERROR_DETAILS;
import static io.ballerina.lib.ibm.ibmmq.Constants.ERROR_ERROR_CODE;
import static io.ballerina.lib.ibm.ibmmq.Constants.ERROR_REASON_CODE;
import static io.ballerina.lib.ibm.ibmmq.Constants.EXPIRY_FIELD;
import static io.ballerina.lib.ibm.ibmmq.Constants.FORMAT_FIELD;
import static io.ballerina.lib.ibm.ibmmq.Constants.IBMMQ_ERROR;
import static io.ballerina.lib.ibm.ibmmq.Constants.MQCIH_RECORD_NAME;
import static io.ballerina.lib.ibm.ibmmq.Constants.MQIIH_RECORD_NAME;
import static io.ballerina.lib.ibm.ibmmq.Constants.MQRFH2_RECORD_NAME;
import static io.ballerina.lib.ibm.ibmmq.Constants.MQRFH_RECORD_NAME;
import static io.ballerina.lib.ibm.ibmmq.Constants.MESSAGE_ACCOUNTING_TOKEN;
import static io.ballerina.lib.ibm.ibmmq.Constants.MESSAGE_CHARSET;
import static io.ballerina.lib.ibm.ibmmq.Constants.MESSAGE_ENCODING;
import static io.ballerina.lib.ibm.ibmmq.Constants.MESSAGE_HEADERS;
import static io.ballerina.lib.ibm.ibmmq.Constants.MESSAGE_ID_FIELD;
import static io.ballerina.lib.ibm.ibmmq.Constants.MESSAGE_PAYLOAD;
import static io.ballerina.lib.ibm.ibmmq.Constants.MESSAGE_PROPERTY;
import static io.ballerina.lib.ibm.ibmmq.Constants.MESSAGE_PROPERTIES;
import static io.ballerina.lib.ibm.ibmmq.Constants.MESSAGE_TYPE_FIELD;
import static io.ballerina.lib.ibm.ibmmq.Constants.MESSAGE_USERID;
import static io.ballerina.lib.ibm.ibmmq.Constants.PD_CONTEXT;
import static io.ballerina.lib.ibm.ibmmq.Constants.PD_COPY_OPTIONS;
import static io.ballerina.lib.ibm.ibmmq.Constants.PD_OPTIONS;
import static io.ballerina.lib.ibm.ibmmq.Constants.PD_SUPPORT;
import static io.ballerina.lib.ibm.ibmmq.Constants.PD_VERSION;
import static io.ballerina.lib.ibm.ibmmq.Constants.PERSISTENCE_FIELD;
import static io.ballerina.lib.ibm.ibmmq.Constants.PRIORITY_FIELD;
import static io.ballerina.lib.ibm.ibmmq.Constants.PROPERTY_DESCRIPTOR;
import static io.ballerina.lib.ibm.ibmmq.Constants.PROPERTY_VALUE;
import static io.ballerina.lib.ibm.ibmmq.Constants.PUT_APPLICATION_TYPE_FIELD;
import static io.ballerina.lib.ibm.ibmmq.Constants.REPLY_TO_QM_NAME_FIELD;
import static io.ballerina.lib.ibm.ibmmq.Constants.REPLY_TO_QUEUE_NAME_FIELD;
import static io.ballerina.lib.ibm.ibmmq.ModuleUtils.getModule;
import static io.ballerina.lib.ibm.ibmmq.headers.MQCIHHeader.createMQCIHHeaderFromBHeader;
import static io.ballerina.lib.ibm.ibmmq.headers.MQIIHHeader.createMQIIHHeaderFromBHeader;
Expand Down Expand Up @@ -105,6 +140,14 @@ public static BMap<BString, Object> getBMessageFromMQMessage(Runtime runtime, MQ
bMessage.put(PUT_APPLICATION_TYPE_FIELD, mqMessage.putApplicationType);
bMessage.put(REPLY_TO_QUEUE_NAME_FIELD, StringUtils.fromString(mqMessage.replyToQueueName.strip()));
bMessage.put(REPLY_TO_QM_NAME_FIELD, StringUtils.fromString(mqMessage.replyToQueueManagerName.strip()));
bMessage.put(MESSAGE_ENCODING, mqMessage.encoding);
bMessage.put(MESSAGE_CHARSET, mqMessage.characterSet);
if (Objects.nonNull(mqMessage.accountingToken)) {
bMessage.put(MESSAGE_ACCOUNTING_TOKEN, ValueCreator.createArrayValue(mqMessage.accountingToken));
}
if (Objects.nonNull(mqMessage.userId)) {
bMessage.put(MESSAGE_USERID, StringUtils.fromString(mqMessage.userId.strip()));
}
byte[] payload = mqMessage.readStringOfByteLength(mqMessage.getDataLength())
.getBytes(StandardCharsets.UTF_8);
bMessage.put(MESSAGE_PAYLOAD, ValueCreator.createArrayValue(payload));
Expand Down

0 comments on commit 4c01768

Please sign in to comment.