class solace.Message extends solace.MessageTracingSupport
This class is not exposed for construction by API users. Users should obtain an instance from solace.SolclientFactory.createMessage
A message is a container that can be used to store and send messages to and from the Solace Message Router.
Applications manage the lifecycle of a message; a message is created by calling solace.SolclientFactory.createMessage and is freed by dereferencing it.
API operations that cache or mutate messages always take a copy. A message may be created, mutated by the API user, and sent multiple times.
The Message Object provides methods to manipulate the common Solace message header fields that are optionally sent in the binary metadata portion of the Solace message.
Applications can also use the structured data API solace.Message#setSdtContainer to add containers (maps or streams) and their fields to the binary payload or to the User Property map contained within the binary metadata.
This does not prevent applications from ignoring these methods and sending payload in the binary payload as an opaque binary field for end-to-end communications
Constructor Top
Message ( ) |
Static Properties & Enumerations Top
SOLCLIENT_USER_PROP_QUEUE_PARTITION_KEY |
Properties Top
readonly Boolean | isAcknowledged | ||
readonly Boolean | isSettled |
Methods Top
Constructor details
Top
Message
( )
This class is not exposed for construction by API users. Users should obtain an instance from
solace.SolclientFactory.createMessage
A message is a container that can be used to store and send messages to and from the
Solace Message Router.
Applications manage the lifecycle of a message; a message is created by calling
solace.SolclientFactory.createMessage and is freed by dereferencing it.
API operations that cache or mutate messages always take a copy. A message may
be created, mutated by the API user, and sent multiple times.
The Message Object provides methods to manipulate the common Solace
message header fields that are optionally sent in the binary metadata
portion of the Solace message.
Applications can also use the structured data API solace.Message#setSdtContainer
to add containers (maps or streams) and their fields to the binary payload or
to the User Property map contained within the binary metadata.
This does not prevent applications from ignoring these
methods and sending payload in the binary payload as an opaque binary field for
end-to-end communications
This class is not exposed for construction by API users. Users should obtain an instance from solace.SolclientFactory.createMessage
A message is a container that can be used to store and send messages to and from the Solace Message Router.
Applications manage the lifecycle of a message; a message is created by calling solace.SolclientFactory.createMessage and is freed by dereferencing it.
API operations that cache or mutate messages always take a copy. A message may be created, mutated by the API user, and sent multiple times.
The Message Object provides methods to manipulate the common Solace message header fields that are optionally sent in the binary metadata portion of the Solace message.
Applications can also use the structured data API solace.Message#setSdtContainer to add containers (maps or streams) and their fields to the binary payload or to the User Property map contained within the binary metadata.
This does not prevent applications from ignoring these methods and sending payload in the binary payload as an opaque binary field for end-to-end communications
Static Properties & Enumerations Detail Top
static
public
SOLCLIENT_USER_PROP_QUEUE_PARTITION_KEY
A standard property key that clients should use if they want to group messages into different queue partitions. Expected value is UTF-8 encoded up to 255 bytes long string.
Properties Detail Top
public
readonly Boolean
isAcknowledged
Returns whether acknowledge() has been called on this message.
public
readonly Boolean
isSettled
Returns whether settle(solace.MessageOutcome) has been called on this message.
Methods Detail Top
public
void
acknowledge
( )
Acknowledges this message. This is the same as calling solace.Message#settle(solace.MessageOutcome.ACCEPTED). Internally uses Message.settle() with the ACCEPTED MessageOutcome.
If the solace.MessageConsumer on which this message was received is configured to use solace.MessageConsumerAckMode.CLIENT, then when a message is received by an application, the application must call this method to explicitly acknowledge reception of the message. This frees local and router resources associated with an unacknowledged message.
The API does not send acknowledgments immediately. It stores the state for acknowledged messages internally and acknowledges messages, in bulk, when a threshold or timer is reached.
public
String
dump
( Number flags )
Produces a human-readable dump of the message's properties and contents. Applications must not parse the output, as its format is not a defined part of the API and subject to change.
Output can be controlled by the flags
parameter. The values are:
- MessageDumpFlag.MSGDUMP_BRIEF Display only the length of the binary attachment, xml attachment, and user property map
- MessageDumpFlag.MSGDUMP_FULL Display the entire message.
public
String
getApplicationMessageId
( )
Gets the application-provided message ID.
public
String
getApplicationMessageType
( )
Gets the application message type. This value is used by applications only, and is passed through the API and Solace Message Router untouched.
Retrieves a solace.Baggage carrier object used for carrying over of the distributed tracing message baggage information across service boundaries. It must not be altered by intermediaries.
public
Uint8Array | String | null
getBinaryAttachment
( )
Gets the binary attachment part of the message.
Backward compatibility note: Using the version10 factory profile or older, the binary attachment is returned as a 'latin1' String: Each character has a code in the range * 0-255 representing the value of a single received byte at that position.
public
Number
getCacheRequestId
( )
Given a Message containing a cached message, return the cache Request Id that the application set in the call to solace.CacheSession#sendCacheRequest.
Gets the cache status of this message.
public
String
getCorrelationId
( )
Gets the correlation ID. The message Correlation Id is carried in the Solace message headers unmodified by the API and the Solace Message Router. This field may be used for peer-to-peer message synchronization and is commonly used for correlating a request to a reply. See solace.Session#sendRequest.
public
Object
getCorrelationKey
( )
Gets the correlation Key. A correlation key is used to correlate a message with its acknowledgement or rejection. The correlation key is an object that is passed back to the client during the router acknowledgement or rejection.
The correlation key is a local reference used by applications generating Guaranteed messages. Messages that are sent in either solace.MessageDeliveryModeType.PERSISTENT or solace.MessageDeliveryModeType.NON_PERSISTENT mode may set the correlation key.
Retrieves a solace.TraceContext object used for carrying over of the distributed tracing message creation context information usable by intermediary instrumentation across service boundaries. It allows correlating the producer with the consumers of a message, regardless of intermediary instrumentation. It must not be altered by intermediaries.
public
Number | undefined
getDeliveryCount
( )
Returns the delivery count.
Gets the delivery mode of the message.
public
Destination
getDestination
( )
Gets the destination to which the message was published.
public
Number | undefined
getGMExpiration
( )
public
Long
getGuaranteedMessageId
( )
This message ID is NOT a universal unique identifier for the message. There is no use for this message ID in an application. Internally this message ID is used when a message is acknowledged calling Message.acknowledge(). No other meaning should be inferred from the value of this message ID.
Deprecated: There is no useful purpose for this method. Do not use it.
public
String
getHttpContentEncoding
( )
Gets the Http Content Encoding
public
String
getHttpContentType
( )
Gets the Http Content Type
public
Number
getPriority
( )
Gets the Message Priority Parameter (JMS Priority) value for the message. Numerical values between 0 and 255 are valid return values, undefined means the parameter is not present.
If destination queues and topic endpoints for this message are configured to respect message priority, the values 0 through 9 can be used to affect the priority of delivery to consumers of those queues or topic endpoints. For the purposes of prioritized message delivery, values larger than 9 are treated the same as 9.
public
Number
getReceiverTimestamp
( )
Gets the receive timestamp (in milliseconds, from midnight, January 1, 1970 UTC).
Returns the Replication Group Message Id
Gets the replyTo destination
public
SDTField | null
getSdtContainer
( )
Gets the message's structured data container, if this is a structured data message.
public
String
getSenderId
( )
Returns the Sender's ID.
public
Number
getSenderTimestamp
( )
Gets the send timestamp (in milliseconds, from midnight, January 1, 1970 UTC).
public
Number
getSequenceNumber
( )
Gets the sequence number.
This is an application-defined field,
see solace.Message#setSequenceNumber()
.
public
Number
getSequenceNumber
( )
Gets the sequence number.
This is an application-defined field,
see solace.Message#setSequenceNumber()
.
public
Number
getTimeToLive
( )
public
Long
getTopicSequenceNumber
( )
Returns the Topic Sequence Number. If there is no topic sequence number undefined is returned.
Retrieves a solace.TraceContextSetter object that is used to modify an appropriate TraceContext associated with a message transparently. When no context is stored in a message it will create and store a creation context with a message that can be used as an initial transport context at the same time. It will never override an existing message creation context. When creation context is present or only transport context is present, it will override an existing transport context information with a newly provided one.
Retrieves a solace.TraceContext object used for carrying over of the distributed tracing transport context information usable or modifiable by intermediary instrumentation across service boundaries. It allows correlating the producer and the consumer with an intermediary. It also allows correlating multiple intermediaries among each other.
Gets the payload type (solace.MessageType) of the message. A message has a structured payload if one was attached via solace.Message#setSdtContainer otherwise if the payload is attached via Message@setBinaryAttachment then it is unstructured (solace.MessageType#BINARY)
Gets the Class of Service (CoS) value for the message. The Class of Service has different semantics for direct and guaranteed messages.
For messages published with solace.MessageDeliveryModeType.DIRECT, the class of service selects the weighted round-robin delivery queue when the message is forwarded to a consumer. solace.MessageUserCosType.COS1 are the lowest priority messages and will use the Solace Message Router D-1 delivery queues.
For messages published as guaranteed messages (solace.MessageDeliveryModeType.PERSISTENT or solace.MessageDeliveryModeType.NON_PERSISTENT), messages published with solace.MessageUserCosType.COS1 can be rejected by the Solace Message Router if that message would cause any queue or topic-endpoint to exceed its configured low-priority-max-msg-count.
public
String
getUserData
( )
Gets the user data part of the message.
Gets the user property map carried in the message binary metadata.
public
String
getXmlContent
( )
Gets the XML content part of the message. Notice that the content is encoded as UTF-8 characters, it needs to be decoded as JavaScript surrogate pair: decodeURIComponent(escape(value))
public
String
getXmlContentDecoded
( )
Gets the XML content part of the message decoded from UTF-8 encoding of the characters.
public
String
getXmlMetadata
( )
Gets the message's XML metadata section.
public
Boolean
isAcknowledgeImmediately
( )
Test if the Acknowledge Immediately message property is set or not. When the Acknowledge Immediately property is set to true on an outgoing Guaranteed Message, it indicates that the Solace Message Router should Acknowledge this message immediately upon receipt.
This property, when set by a publisher, may or may not be removed by the Solace Message Router prior to delivery to a consumer, so message consumers must not expect the property value indicates how the message was originally published
public
Boolean
isDeliverToOne
( )
Gets whether the message is configured for delivering to one client only.
Deprecated: use Shared Subscriptions instead.
public
Boolean
isDiscardIndication
( )
Indicates whether one or more messages have been discarded prior to the current message. This indicates congestion discards only and is not affected by message eliding.
public
Boolean
isDMQEligible
( )
public
Boolean
isElidingEligible
( )
Returns whether the message is eligible for eliding.
Message eliding enables filtering of data to avoid transmitting every single update to a subscribing client.
This property does not indicate whether the message was elided.
public
Boolean
isRedelivered
( )
Indicates whether the message has been marked as redelivered by the Solace Message Router.
public
Boolean
isReplyMessage
( )
Returns whether the message's reply field is set, indicating that this message is a reply to a previous request. See solace.Session#sendRequest.
public
void
reset
( )
Releases all memory associated with this message. All values are reinitialized to defaults. The message is no longer associated with any session or consumer.
public
void
setAcknowledgeImmediately
( Boolean value )
Set the optional Acknoweledge Immediately message property. When the Acknowledge Immediately property is set to true on an outgoing Guaranteed Message, it indicates that the Solace Message Router should acknoweledge this message immediately upon receipt. By default the property is set to false on newly created messages.
This property, when set by a publisher, may or may not be removed by the appliance prior to delivery to a consumer, so message consumers must not expect the property value indicates how the message was originally published. Therefore if a received message is forwarded by the application, the Acknowledge Immediately property should be explicitly set to the desired value (true or false).
Setting this property on an outgoing direct message has no effect.
public
void
setApplicationMessageId
( String value )
Sets the application-provided message ID.
public
void
setApplicationMessageType
( String value )
Sets the application message type. This value is used by applications only, and is passed through the API and Solace Message Router untouched.
public
void
setAsReplyMessage
( Boolean value )
Sets the reply field of the message.
public
void
setBinaryAttachment
( Uint8Array | ArrayBufferLike | DataView | String | null | undefined value )
Sets the binary attachment part of the message.
The binary attachment is conceptually an array of bytes. When this method is used, the message payload type is solace.MessageType#BINARY See solace.Message#getType.
Applications may set the binary attachment to NULL or undefined to remove the binary attachment and create a message with no payload.
The following types are accepted: Buffer (the nodeJS native type or equivalent) ArrayBuffer, Any DataView or TypedArray, 'latin1' String for backwards compatibility: each character has a code in the range 0-255 representing exactly one byte in the attachment.
public
void
setCorrelationId
( String | null | undefined value )
Sets the correlation ID. The message Correlation Id is carried in the Solace message headers unmodified by the API and the Solace Message Router. This field may be used for peer-to-peer message synchronization and is commonly used for correlating a request to a reply. See solace.Session#sendRequest.
public
void
setCorrelationKey
( Object | String | null | undefined value )
Sets the correlation Key. A correlation key is used to correlate a message with its acknowledgement or rejection. The correlation key is an object that is passed back to the client during the router acknowledgement or rejection.
The correlation key is a local reference used by applications generating Guaranteed Messages. Messages that are sent in either solace.MessageDeliveryModeType.PERSISTENT or solace.MessageDeliveryModeType.NON_PERSISTENT mode may set the correlation key. If this method is used, the correlation information is returned when the solace.SessionEventCode#event:ACKNOWLEDGED_MESSAGE event is later received for an acknowledged message or when the solace.SessionEventCode#event:REJECTED_MESSAGE_ERROR is received for a rejected message.
The API only maintains a reference to the passed object. If the application requires the contents are unmodified for proper correlation, then it is the application's responsibility to ensure the contents of the object are not modified.
Important: The Correlation Key is not included in the transmitted message and is only used with the local API
public
void
setDeliverToOne
( Boolean value )
Sets whether the message is configured for delivering to one client only.
Deprecated: use Shared Subscriptions instead.
Sets the delivery mode of the message.
public
void
setDestination
( Destination value )
Sets the destination (solace.DestinationType#Topic or solace.DestinationType#Queue) to publish the message to.
public
void
setDMQEligible
( Boolean value )
public
void
setElidingEligible
( Boolean value )
Sets whether the message is eligible for eliding.
Message eliding enables filtering of data to avoid transmitting every single update to a subscribing client.
This property does not indicate whether the message was elided.
public
void
setGMExpiration
( Number value )
Set the expiration time field. The expiration time is the UTC time (that is, the number of milliseconds from midnight January 1, 1970 UTC) when the message is to expire. The expiration time is carried in the message when set to a non-zero value. Expiration time is not included when this value is set to zero or undefined
The message expiration time is carried to clients that receive the message unmodified and does not effect the life cycle of the message. Use solace.Message#setTimeToLive to enforce message expiry in the network.
public
void
setHttpContentEncoding
( String value )
Sets the Http Content Encoding
public
void
setHttpContentType
( String value )
Sets the Http Content Type
public
void
setPriority
( Number value )
Sets the Message Priority Parameter (JMS Priority) value for the message. Numerical values between 0 and 255 are accepted, use undefined to unset.
If destination queues and topic endpoints for this message are configured to respect message priority, the values 0 through 9 can be used to affect the priority of delivery to consumers of those queues or topic endpoints. For the purposes of prioritized message delivery, values larger than 9 are treated the same as 9.
Sets the replyTo destination
Makes this message a strutured data message by assigning it a structured data type (SDT) container payload (such as a solace.SDTMapContainer, solace.SDTStreamContainer or a solace.SDTFieldType.String, which is transported in the binary attachment field.
Assigning a SDT container updates the message's Type property to the appropriate value.
The container argument must be a solace.SDTField with a type of solace.SDTFieldType.MAP, solace.SDTFieldType.STREAM, or solace.SDTFieldType.STRING.
public
void
setSenderId
( String value )
Sets the Sender ID for the message
public
void
setSenderTimestamp
( Number value )
Sets the send timestamp (in milliseconds, from midnight, January 1, 1970 UTC). This field can be generated automatically during message publishing, but it will not be generated if previously set to a non-null value by this method. See solace.SessionProperties#generateSendTimestamps.
An application that publishes the same solace.Messsage multiple times and also wants generted timestamps on each messages, should set the sender timestamp to undefined after each call to solace.Session#send.
public
void
setSequenceNumber
( Number value )
Sets the application-defined sequence number. If the sequence number is not set, or set to undefined, and solace.SessionProperties#generateSequenceNumber is true, then a sequence number is automatically generated for each sent message.
public
void
setTimeToLive
( Number value )
Settles this message in a requested way.
If the solace.MessageConsumer on which this message was received is configured to use solace.MessageConsumerAckMode.CLIENT, then when a message is received by an application, the application must call this method to explicitly acknowledge reception of the message. This frees local and router resources associated with an unacknowledged message.
The API does not send acknowledgments immediately. It stores the state for acknowledged messages internally and acknowledges messages, in bulk, when a threshold or timer is reached.
See solace.MessageOutcomefor detailed explanation of available options
Set the transport context. Called when the message is received from broker
Sets the Class of Service (CoS) value for the message.
The Class of Service has different semantics for direct and guaranteed messages.
For messages published with solace.MessageDeliveryModeType.DIRECT, the class of service selects the weighted round-robin delivery queue when the message is forwarded to a consumer. solace.MessageUserCosType#COS1 are the lowest priority messages and will use the Solace Message Router D-1 delivery queues.
For messages published as guaranteed messages (solace.MessageDeliveryModeType.PERSISTENT or solace.MessageDeliveryModeType.NON_PERSISTENT), messages published with solace.MessageUserCosType#COS1 can be rejected by the Solace Message Router if that message would cause any queue or topic-endpoint to exceed its configured low-priority-max-msg-count.
public
void
setUserData
( String value )
Sets the user data part of the message.
public
void
setUserPropertyMap
( SDTMapContainer value )
Allows users to specify their own user properties to be carried in the message binary metadata separate from the payload.
public
void
setXmlContent
( String value )
Sets the XML content part of the message. The content is encoded by replacing each instance of certain characters by one, two, three, or four escape sequences representing the UTF-8 encoding of the character.
public
void
setXmlMetadata
( String value )
Sets the message's XML metadata section.