Creating Messages
Messages are explicitly created by client applications when publishing and are implicitly created by the messaging APIs on matching message delivery.
The Solace .NET API creates an IMessage object to encapsulate a message.
When creating messages, the following factors should be considered:
Message Ownership
When creating messages for publishing, there are two message ownership models:
- Session-independent
In a session‑independent message ownership model, client applications can reuse messages between send operations. Messages are allocated on demand and are disposed explicitly by client applications when they are done with the messages.
To Create Session-Independent Messages
In the Solace .NET API, you can use:
-
ContextFactory.CreateMessage() -
ISession.CreateMessage()Creates an
IMessageobject to encapsulate a message.
Related Samples
For an example of how to create session‑independent messages, see the DirectPubSub sample for the Solace .NET API.
Message Types
The Solace .NET API defines only a single message type. A message payload can contain any combination of message types by way of message helper functions.
Resetting Messages
When reusing a message in the session-independent message ownership model, you can release all memory associated with a message buffer so that the message buffer is reset to its original state (that is, as if it has just been allocated). All fields are reset to their default values.
To reset a message in the Solace .NET API, use IMessage.reset().