Creating Messages
Messages are explicitly created by client applications when publishing and are implicitly created by the Solace Java RTO API on matching message delivery. The Solace Java RTO API creates an object within the native library and provides a handle to the application.
When creating messages, the following factors should be considered:
Message Ownership
When creating messages for publishing, there is one message ownership model:
- 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
To create session-independent messages, use the Solclient.createMessageForHandle(...) method. This allocates a new message that is bound to the given unbound MessageHandle.
Related Samples
For an example of how to create session‑independent messages, see the DirectPubSub sample for the Solace Java RTO API.
To Create Session-Dependent Messages
Not applicable for Solace Java RTO API.
Message Types
The Solace Java RTO API supports the BytesMessage class for sending messages that contain a stream of uninterpreted bytes in a binary attachment.
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.
The Solace Java RTO API does not include a reset method. If a message is destroyed using MessageHandle.destroy(), you must call createMessageForHandle again to allocate a new message for the now-unbound handle.
To Reset a Message
Not applicable for Solace Java RTO API.