public interface ErrorListener
-err
protocol operation.All of these problems are reported to the application code using the ErrorListener. The
listener is configured in the Options
at creation time.
Modifier and Type | Interface and Description |
---|---|
static class |
ErrorListener.FlowControlSource |
Modifier and Type | Method and Description |
---|---|
default void |
errorOccurred(Connection conn,
java.lang.String error)
NATs related errors that occur asynchronously in the client library are sent
to an ErrorListener via errorOccurred.
|
default void |
exceptionOccurred(Connection conn,
java.lang.Exception exp)
Exceptions that occur in the "normal" course of operations are sent to the
ErrorListener using exceptionOccurred.
|
default void |
flowControlProcessed(Connection conn,
JetStreamSubscription sub,
java.lang.String subject,
ErrorListener.FlowControlSource source)
Called by the connection when a flow control is processed.
|
default void |
heartbeatAlarm(Connection conn,
JetStreamSubscription sub,
long lastStreamSequence,
long lastConsumerSequence)
Called when subscription heartbeats are missed according to the configured period and threshold.
|
default void |
messageDiscarded(Connection conn,
Message msg)
Called by the connection when a message is discarded.
|
default void |
pullStatusError(Connection conn,
JetStreamSubscription sub,
Status status)
Called when a pull subscription receives a status message that indicates either
the subscription cannot continue or the pull request cannot be processed.
|
default void |
pullStatusWarning(Connection conn,
JetStreamSubscription sub,
Status status)
Called when a pull subscription receives a status message that indicates either
the subscription or pull might be problematic
|
default void |
slowConsumerDetected(Connection conn,
Consumer consumer)
Called by the connection when a "slow" consumer is detected.
|
default void |
socketWriteTimeout(Connection conn)
Called by the connection when a low level socket write timeout occurs.
|
default java.lang.String |
supplyMessage(java.lang.String label,
Connection conn,
Consumer consumer,
Subscription sub,
java.lang.Object... pairs)
General message producing function which understands the possible parameters to listener calls.
|
default void |
unhandledStatus(Connection conn,
JetStreamSubscription sub,
Status status)
Called when an unhandled status is received in a push subscription.
|
default void errorOccurred(Connection conn, java.lang.String error)
The text for an error is described in the protocol doc at `https://nats.io/documentation/internals/nats-protocol`.
In some cases the server will close the clients connection after sending one of these errors. In that case, the
connections ConnectionListener
will be notified.
conn
- The connection associated with the errorerror
- The text of error that has occurred, directly from the serverdefault void exceptionOccurred(Connection conn, java.lang.Exception exp)
conn
- The connection associated with the errorexp
- The exception that has occurred, and was handled by the librarydefault void slowConsumerDetected(Connection conn, Consumer consumer)
See Consumer.setPendingLimits
for information on how to configure when this method is fired.
Slow consumers will result in dropped messages each consumer provides a method
for retrieving the count of dropped messages, see Consumer.getDroppedCount
.
conn
- The connection associated with the errorconsumer
- The consumer that is being marked slowdefault void messageDiscarded(Connection conn, Message msg)
conn
- The connection that discarded the messagemsg
- The message that is discardeddefault void heartbeatAlarm(Connection conn, JetStreamSubscription sub, long lastStreamSequence, long lastConsumerSequence)
conn
- The connection that had the issuesub
- the JetStreamSubscription that this occurred onlastStreamSequence
- the last received stream sequencelastConsumerSequence
- the last received consumer sequencedefault void unhandledStatus(Connection conn, JetStreamSubscription sub, Status status)
conn
- The connection that had the issuesub
- the JetStreamSubscription that this occurred onstatus
- the statusdefault void pullStatusWarning(Connection conn, JetStreamSubscription sub, Status status)
conn
- The connection that had the issuesub
- the JetStreamSubscription that this occurred onstatus
- the statusdefault void pullStatusError(Connection conn, JetStreamSubscription sub, Status status)
conn
- The connection that had the issuesub
- the JetStreamSubscription that this occurred onstatus
- the statusdefault void flowControlProcessed(Connection conn, JetStreamSubscription sub, java.lang.String subject, ErrorListener.FlowControlSource source)
conn
- The connection that had the issuesub
- the JetStreamSubscription that this occurred onsubject
- the flow control subject that was handledsource
- enum indicating flow control handling in response to which type of messagedefault void socketWriteTimeout(Connection conn)
conn
- The connection that had the issuedefault java.lang.String supplyMessage(java.lang.String label, Connection conn, Consumer consumer, Subscription sub, java.lang.Object... pairs)
label
- the label for the messageconn
- The connection that had the issue, if provided.consumer
- The consumer that is being marked slow, if applicablesub
- the JetStreamSubscription that this occurred on, if applicablepairs
- custom string pairs. I.E. "foo: ", fooObject, "bar-", barObject will be appended
to the message like ", foo: <fooValue>, bar-<barValue>".