Using Structured Data in the Solace JCSMP API
SDTs are structured, language-independent, and architecture-independent data types. SDTs can be used in messages to facilitate the exchange of binary data in a heterogeneous network that has clients that use different hardware architectures and programming languages.
The Solace JCSMP API supports the ability to carry structured data in the binary attachment of the message or as user-defined message header fields.
All structured data must be added to or read from complex data structures (maps and streams), generically called containers. Containers themselves are structured data types. Therefore, a map or stream can contain simple SDT types or other maps or streams.
Related Samples
- For an example of how to work with SDTs when publishing and receiving messages, see the RequestReply samples (
RRDirectRequester, RRDirectReplier, RRGuaranteedRequester, and RRGuaranteedReplier) in the Solace Developer Hub. - For an example of how to add SDT payloads to a message, see the
SDTPubSubMsgIndeporSDTPubSubMsgDepsamples in the Solace Developer Hub..- In the
SDTPubSubMsgIndepsample, SDT containers are created using application memory, allowed by the Solace JCSMP API. - For more information on creating SDT containers with application memory, see the Creating Structured Data Maps and Streams in the Solace JCSMP API.
- In the
Supported Structured Data Types
The Solace JCSMP API supports the following SDTs.
| Data Type | JCSMP |
|---|---|
|
Boolean |
java.lang.Boolean |
|
8-bit signed integer |
java.lang.Byte |
|
8-bit unsigned integer |
Not applicable |
|
16-bit signed integer |
java.lang.Short |
|
16-bit unsigned integer |
Not applicable |
|
32-bit signed integer |
java.lang.Integer |
|
32-bit unsigned integer |
Not applicable |
|
64-bit signed integer |
java.lang.Long |
|
64-bit unsigned integer |
Not applicable |
|
32-bit floating point |
float |
|
64-bit floating point |
double |
|
character (16-bit unicode) |
java.lang.Character |
|
byte array |
byte[] |
|
string (UTF-8 encoded) |
java.lang.String |
|
destination (Topic or Queue physical names) |
com.solacesystems. |
|
SMF message |
com.solacesystems. |
|
Map (a structured data container of a sequence of named fields. Each field must be one of the supported data types.) |
SDTMap |
|
Stream (a structured data container of a sequence of unnamed fields. Each field must be one of the supported data types.) |
SDTStream |
|
Unknown (a validly formatted but unrecognized data type) |
com.solacesystems. |
|
Null or unspecified |
null |
Structured Data Type Conversion
The table below lists how the supported SDTs in a received message can be read by the Solace JCSMP API.
| Read As | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Bool | Byte | Byte[ ] | Char | Dest | Dbl | Float | Int | Long | Map | Msg | Short | Stream | String | ||
|
Written As |
Bool |
✓ |
|
|
|
|
|
|
|
|
|
|
|
|
✓ |
|
Byte |
|
✓ |
|
|
|
|
|
✓ |
✓ |
|
|
✓ |
|
✓ |
|
|
Byte[ ] |
|
|
✓ |
|
|
|
|
|
|
|
|
|
|
|
|
|
Char |
|
|
|
✓ |
|
|
|
|
|
|
|
|
|
✓ |
|
|
Dest |
|
|
|
|
✓ |
|
|
|
|
|
|
|
|
|
|
|
Dbl |
|
|
|
|
|
✓ |
|
|
|
|
|
|
|
✓ |
|
|
Float |
|
|
|
|
|
✓ |
✓ |
|
|
|
|
|
|
✓ |
|
|
Int |
|
2 |
|
|
|
|
|
✓ |
✓ |
|
|
2 |
|
✓ |
|
|
Long |
|
2 |
|
|
|
|
|
2 |
✓ |
|
|
2 |
|
✓ |
|
|
Map |
|
|
|
|
|
|
|
|
|
✓ |
|
|
|
|
|
|
Msg |
|
|
|
|
|
|
|
|
|
|
✓ |
|
|
|
|
|
Short |
|
2 |
|
|
|
|
|
2 |
2 |
|
|
✓ |
|
✓ |
|
|
Stream |
|
|
|
|
|
|
|
|
|
|
|
|
✓ |
|
|
|
String |
1 |
✓ |
|
|
|
✓ |
✓ |
✓ |
✓ |
|
|
✓ |
|
✓ |
|
|
1. Returns a Boolean with a value represented by the specified string. The Boolean returned represents a true value if the string argument is not null and is equal, ignoring case, to the string “true”. 2. If a lossless conversion. |
|||||||||||||||