Using Structured Data
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 JavaScript API and Solace Node.js API support 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
BasicRequestorandBasicRepliersamples for the Solace JavaScript API and Solace Node.js API.
Supported Structured Data Types
The Solace JavaScript API and Solace Node.js API support the following SDTs.
| Data Type | Solace JavaScript API and Solace Node.js API |
|---|---|
|
Boolean |
boolean |
|
8-bit signed integer |
number |
|
8-bit unsigned integer |
number |
|
16-bit signed integer |
number |
|
16-bit unsigned integer |
number |
|
32-bit signed integer |
number |
|
32-bit unsigned integer |
number |
|
64-bit signed integer |
number Supports 48-bit integers (range: 0 to 2^48-1). When encoding, only the lower 48 bits are considered significant. |
|
64-bit unsigned integer |
number Supports 48-bit integers (range: 0 to 2^48-1). When encoding, only the lower 48 bits are considered significant. |
|
32-bit floating point |
number Single-precision float. |
|
64-bit floating point |
number Double-precision float. |
|
character (16-bit unicode) |
string Single character. |
|
byte array |
Int8Array |
|
string (UTF-8 encoded) |
string |
|
destination (Topic or Queue physical names) |
solace.Destination |
|
SMF message |
solace.Message |
|
Map (a structured data container of a sequence of named fields. Each field must be one of the supported data types.) |
solace.SDTMapContainer |
|
Stream (a structured data container of a sequence of unnamed fields. Each field must be one of the supported data types.) |
solace.SDTStreamContainer |
|
Unknown (a validly formatted but unrecognized data type) |
Using solace.SDTFieldType.UNKNOWN |
|
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 JavaScript API and Solace Node.js 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. |
|||||||||||||||