ballerina-spec icon indicating copy to clipboard operation
ballerina-spec copied to clipboard

[Discussion] Proposal to improve `jms:Message` record to be compliant with JMS specification

Open ayeshLK opened this issue 5 months ago • 2 comments

Please use this issue to discuss the Proposal to improve the jms:Message record to include union-typed content field

ayeshLK avatar Jul 04 '25 08:07 ayeshLK

@ayeshLK Why don't we make the content field's type anydata (not restricting to string|byte[]|map<anydata>)? It will cover all the types JMS supports and look more Ballerina-idiomatic.

gimantha avatar Jul 04 '25 14:07 gimantha

@gimantha As per the Ballerina spec, the anydata type includes [1]

() | boolean | int | float | decimal | string | xml | regexp:RegExp | anydata[] | map<anydata> | table<map<anydata>>

This allows users to use value types that may not be supported by the JMS specification. However, according to the JMS spec, the supported types for message content and properties are more restricted. Specifically, JMS supports: *

  • string
  • byte[]
  • map<string, value> where value is limited to primitive types like boolean, int, byte, float, string, and byte[] (for MapMessage)
  • stream message (a stream of Java primitive values written and read sequentially)
  • object types (i.e., serialized Java objects)

Given this mismatch, using anydata as the value type in the content or properties fields is not accurate for this context. We should instead define more constrained union types that align with the JMS spec to avoid runtime issues and improve compatibility.

[1] - https://ballerina.io/spec/lang/master/#anydata

ayeshLK avatar Jul 09 '25 08:07 ayeshLK