Managing Messages in the Solace .NET API
The following sections discuss how you can manage messages when you use the Solace .NET API.
Getting Message Properties
A client can obtain message properties from a created message before it is published or from a message the API receives from the event broker.
For a complete list of message properties that can be retrieved, see the Solace .NET API reference documentation.
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.
In the Solace .NET API, use all IMessage.Get*() methods. For example:
-
IMessage.GetBinaryAttachment() -
IMessage.GetDestinationTopicSuffix() -
IMessage.GetUserData()
For a complete list of methods, see the Solace Messaging API for .NET 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 Solace .NET API reference documentation.
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.
In the Solace .NET API, use all IMessage.Set*() methods. For example:
-
IMessage.SetBinaryAttachment (sbyte[] binaryAttachment) -
IMessage.SetUserData (sbyte[] userData) -
IMessage.SetXmlContent (sbyte[] xmlContent)
For a complete list of methods, see the Solace Messaging API for .NET reference.
Duplicating Messages
The Solace .NET API does not provide functionality to duplicate messages.
Displaying Messages
You can use the message dump utility to display the contents of a message in a human‑readable form. This utility method 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.
In the Solace .NET API, use:
IMessage.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.
Freeing Messages
When using the Solace .NET API, a client should free a message when it is finished with it so that the memory allocated to the message is freed. Clients should free outbound messages after publishing them, and free inbound messages after they finish processing them.
When the call successfully returns, the memory that was referenced by the freed message is no longer valid.
In the Solace .NET API, use:
Dispose()