Adding Data Payloads in the PubSub+ JCSMP API

You can add the following types of payloads to a PubSub+ JCSMP API message:

  • XML content—XML data can be added to the XML content part of a message.
  • Binary content—Binary data can be added to a message as a binary attachment. A message can only contain a single attachment.

    When this attachment is sent through the event broker, it is not processed, transformed, or considered in subscription matching or filtering operations. This provides an efficient means for sending data that does not require processing by the platform before it reaches receiving applications.

    Structured data can also be added as a payload in the binary attachment (refer to Using Structured Data in the PubSub+ JCSMP API).

  • User Property Map—Structured data can be added to user-defined message header fields.
  • User Data—Up to 36 bytes of application‑specific binary data, known as user data, can be added to the User Data message header field.

The maximum total size permitted for a published Direct message is 64 MiB (67,108,864 bytes). This is an event broker-imposed limit, and it takes into consideration the message header field data, XML metadata, XML payload, and any attachments.

To Add Data Payloads to a Message

Data Type To Add Set Through

XML Data

  • setXMLContent(...)

    Sets the XML data payload content for an XMLContentMessage.

  • writeBytes(...)

    Sets the XML data payload content for an unstructured XML message.

Binary Data

writeAttachment(...)

You can also use the structured BytesMessage message class to create a message that contains a data payload in the binary attachment.

User Data

setUserData(...)

MessageProducer does not validate the values of user data.

Related Samples

  • For an example of how to add a binary data payload to a message, refer to DirectPubSub
  • For an example of how to add SDT payloads to a message, refer to the SDTPubSubMsgIndep or SDTPubSubMsgDep samples
    • In the SDTPubSubMsgIndep sample, SDT containers are created using application memory (allowed by the JCSMP API).

    For more information on creating SDT containers with application memory or API-controlled memory, refer to Using Structured Data in the PubSub+ JCSMP API.