Managing Messages
The following sections discuss how you can manage messages when you use the Solace JavaScript API and Solace Node.js API.
Getting Message Properties
A client can obtain message properties from a created message before it is published or from a message the Solace JavaScript API and Solace Node.js API receives from the event broker.
For a complete list of message properties that can be retrieved, see the appropriate API in the Solace Messaging APIs section.
Some message properties, such as expiration, TTL and dead message queue eligibility, are only valid when used with guaranteed messages. See the relevant API reference documentation for more information.
To get message properties, use all solace.Message.get*() functions. For example:
-
solace.Message.getApplicationMessageType ( ) -
solace.Message.getDeliveryMode ( ) -
solace.Message.getSenderId ( )
For a complete list of methods, see the Solace JavaScript API reference.
Setting Message Properties
A client can set message properties on a created message before it is published or on a message the API receives from the event broker.
For a complete list of message properties that can be set, see the appropriate API in the Solace Messaging APIs section.
Some message properties, such as expiration, TTL and dead message queue eligibility, are only valid when used with guaranteed messages. See the relevant API reference documentation for more information.
To set message properties, use all solace.Message.set*() functions. For example:
-
solace.Message.setApplicationMessageType ( String value ) -
solace.Message.setDeliveryMode ( solace.MessageDeliveryModeType value ) -
solace.Message.setSenderId ( String value )
For a complete list of methods, see the Solace JavaScript API reference.
Displaying Messages
You can use the message dump utility to display the contents of a message in a human‑readable form. This utility method or function is provided as a programming aid to facilitate the development and testing of messaging applications. You can display the contents of a created message or a received message.
To display message contents, call Solace.Message.dump().
The format of the generated output is:
<field>: <value>
For example, a message part, such as a message header field like SenderId, is displayed as:
SenderId: mySenderID
If a message part is present in the message, but it contains NULL or an empty string, the field is displayed (in this case, SenderID:) but no value is present. If a message part is not present, then no output is generated for that part. For example, if there is no SenderId header field, then no SenderId field or value is generated.