Creating Structured Data Maps and Streams

The Solace JavaScript API and Solace Node.js API support message-independent maps and streams, where containers are created in application memory independent of a particular message.

Message-Independent Maps and Streams

Typically, a map or stream is created in application memory that is independent of a particular message. This allows a container to be added to other containers or to the binary message parts of more than just one message. Using a message‑independent container can be useful if you want to add it repeatedly to different messages or to existing containers as a common container.

For the Solace JavaScript API and Solace Node.js API, when a container is created, memory is allocated for it from the heap.

The following sections discuss how to use containers that are message‑independent:

Creating Structured Data Maps

To create a structured data map, create a new solace.SDTMapContainer object.

Creating Structured Data Streams

To create a structured data stream, create a new solace.SDTStreamContainer object.

Adding Content from Containers to Messages by Reference

To add data from a map or a stream into a message's binary attachment through a container reference, create a new SDT field object, passing in the SDT map or stream container object to be added by reference using solace.SDTField.create(...), then pass the SDT field object to message.setSdtContainer(...).

If the message already has a binary attachment, it is removed and only the referenced map is transmitted.

Adding Containers to Existing Containers

To add an existing container to a map or stream, create a new SDT field object, passing in the SDT map or stream container object to be added using solace.SDTField.create(...), then use the addField(...) method to add it to the SDT map or stream container.

Data fields, submaps, and substreams can be created using SDT add methods.