Skip to content

Commit

Permalink
Merge pull request #124 from ayeshLK/jms-examples
Browse files Browse the repository at this point in the history
[FIX] JMS message retrieval fails for JMS 1.x unsupported properties
  • Loading branch information
ayeshLK authored Mar 20, 2024
2 parents 3ae9b51 + 0524a6d commit e1c5aed
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- [Add observability support to the JMS module](https://github.com/ballerina-platform/ballerina-library/issues/5932)

### Fixed
- [JMS message retrieval fails for JMS 1.x unsupported properties](https://github.com/ballerina-platform/ballerina-library/issues/6204)

## [0.1.0] - 2023-07-24

### Changed
Expand Down
15 changes: 12 additions & 3 deletions native/src/main/java/io/ballerina/stdlib/java.jms/CommonUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ public static BMap<BString, Object> getBallerinaMessage(Message message)
BMap<BString, Object> ballerinaMessage = ValueCreator.createRecordValue(ModuleUtils.getModule(), messageType);
ballerinaMessage.put(Constants.MESSAGE_ID, StringUtils.fromString(message.getJMSMessageID()));
ballerinaMessage.put(Constants.TIMESTAMP, message.getJMSTimestamp());
ballerinaMessage.put(Constants.CORRELATION_ID, StringUtils.fromString(message.getJMSCorrelationID()));
if (Objects.nonNull(message.getJMSCorrelationID())) {
ballerinaMessage.put(Constants.CORRELATION_ID, StringUtils.fromString(message.getJMSCorrelationID()));
}
if (Objects.nonNull(message.getJMSReplyTo())) {
ballerinaMessage.put(Constants.REPLY_TO, getJmsDestinationField(message.getJMSReplyTo()));
}
Expand All @@ -115,9 +117,16 @@ public static BMap<BString, Object> getBallerinaMessage(Message message)
}
ballerinaMessage.put(Constants.DELIVERY_MODE, message.getJMSDeliveryMode());
ballerinaMessage.put(Constants.REDELIVERED, message.getJMSRedelivered());
ballerinaMessage.put(Constants.JMS_TYPE, StringUtils.fromString(message.getJMSType()));
if (Objects.nonNull(message.getJMSType())) {
ballerinaMessage.put(Constants.JMS_TYPE, StringUtils.fromString(message.getJMSType()));
}
ballerinaMessage.put(Constants.EXPIRATION, message.getJMSExpiration());
ballerinaMessage.put(Constants.DELIVERED_TIME, message.getJMSDeliveryTime());
try {
ballerinaMessage.put(Constants.DELIVERED_TIME, message.getJMSDeliveryTime());
} catch (UnsupportedOperationException e) {
// This exception occurs when the client connect to a JMS provider who supports JMS 1.x.
// Hence, ignoring this exception.
}
ballerinaMessage.put(Constants.PRIORITY, message.getJMSPriority());
ballerinaMessage.put(Constants.PROPERTIES, getMessageProperties(message));
Object content = getMessageContent(message);
Expand Down

0 comments on commit e1c5aed

Please sign in to comment.