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 | Method and Description |
---|---|
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.
|
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 |
messageDiscarded(Connection conn,
Message msg)
Called by the connection when a message is discarded.
|
void |
slowConsumerDetected(Connection conn,
Consumer consumer)
Called by the connection when a "slow" consumer is detected.
|
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 servervoid exceptionOccurred(Connection conn, java.lang.Exception exp)
conn
- The connection associated with the errorexp
- The exception that has occurred, and was handled by the libraryvoid 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 discarded