@ProviderType
public interface PublisherHealthCheck
Modifier and Type | Interface and Description |
---|---|
static interface |
PublisherHealthCheck.PublisherReadinessListener
An interface that is abstraction for the handling of a publisher instance's ability to take new
messages and send them over the wire to a remote broker.
|
Modifier and Type | Method and Description |
---|---|
boolean |
isReady()
A non-blocking check to determine if the publisher can potentially publish messages.
|
void |
notifyWhenReady()
A non-blocking request to notify
PublisherHealthCheck.PublisherReadinessListener . |
void |
setPublisherReadinessListener(PublisherHealthCheck.PublisherReadinessListener listener)
Sets a publisher readiness listener when supported, to be used with rejecting back pressure
strategy.
|
boolean isReady()
false
if nothing prevents publisher from sending messages including i.e., full
buffer or I/O problems; true
otherwisevoid notifyWhenReady()
PublisherHealthCheck.PublisherReadinessListener
.
This method can help to overcome a possible race condition that may occur between the
completing the processing of an exception and publishing an event when in the READY state
(i.e., when sending an event).
Example usage is demonstrated as follows:
...
boolean exitExceptionally = false;
try {
messagePublisher.publish(message, toDestination);
} catch (PublisherOverflowException overflowException) {
// perform tasks in case of overflow
exitExceptionally = true;
} catch (PubSubPlusClientException exception) {
// perform tasks based on exception
// may call exitExceptionally = true;
} finally {
if (exitExceptionally) {
// request a notification on
messagePublisher.notifyWhenReady();
}
}
void setPublisherReadinessListener(PublisherHealthCheck.PublisherReadinessListener listener)
listener
- the listener to listen for publisher state changesCopyright 2019-2024 Solace Corporation. All rights reserved.