Sending Guaranteed Messages
When sending a Guaranteed message, client applications must consider the following factors:
- The number of messages to publish per send invocation. See Sending One Message at a Time.
- Whether you want to send messages that require a reply from the receiver. See Publishing Messages that Request Replies.
-
If you are publishing in a network environment that experiences higher than usual delays, you might need to adjust the Guaranteed message publish window size (see Adjusting the Guaranteed Message Publish Window Size ) or acknowledgment timer (see Adjusting the Guaranteed Message Publish ACK Timer).
Sending Messages Larger Than the Event Broker's Maximum Message Size
You cannot publish a Guaranteed message larger than the event broker's maximum Guaranteed message size—30MB in most cases. If you try to publish a message that exceeds the maximum size, the Solace Messaging APIs return an error, throw an exception, or raise an error with the subcode MESSAGE_TOO_LARGE. To prevent disruptions, design your application to control message sizes and ensure they stay within the supported limit.
Adjusting the Guaranteed Message Publish Window Size
The Guaranteed message publish window size can be adjusted, if necessary, to better suit your messaging environment. The valid range is 1 through 255.
Although the default value has been proven to provide good performance for most LAN situations, increasing the value might help in a situation where messages are being published over a WAN or a network with higher delay (possibly incurring event broker/switch induced latencies), and the window is experiencing flow control situations.
Windowed acknowledgment properties have no effect for Direct messages.
To set the Guaranteed message publish window size, use solace.MessagePublisherProperties.windowSize, where the solace.MessagePublisherProperties object is assigned to solace.SessionProperties.publisherProperties.
Adjusting the Guaranteed Message Publish ACK Timer
The Guaranteed message publish acknowledgment timer sets the amount of time (in milliseconds) that the publishing API will wait for an acknowledgment from the event broker before resending. Guaranteed messages not acknowledged within the publish acknowledgment time are retransmitted automatically by the API.
Although the default Guaranteed message publish acknowledgment timer value has been proven to provide good performance, it can be adjusted, if necessary.
Windowed acknowledgment properties have no effect for Direct messages.
To adjust the Guaranteed message publish acknowledgment timer, use solace.MessagePublisherProperties.acknowledgeTimeoutInMsecs, where the solace.MessagePublisherProperties object is assigned to solace.SessionProperties.publisherProperties.
Sending One Message at a Time
To publish a single message per API call, use solace.Session.send(...).
Message Correlation
When using Guaranteed messaging, a correlation key or tag is used to correlate a message with its ACK or NACK.
To set the correlation key property of a message, use message.setCorrelationKey(...). The correlation key is passed back to the client in the listeners for the following events:
solace.SessionEventCode.ACKNOWLEDGED_MESSAGEsolace.SessionEventCode.REJECTED_MESSAGE_ERROR