Class ConnectionBlockedException
- All Implemented Interfaces:
Serializable
RabbitMQ blocks publishing connections when it runs low on memory or disk, and the way it
does so is quiet: the socket stops draining, basicPublish keeps returning, and the
confirm never arrives. A publisher that waits for confirms then waits forever — no exception,
no timeout, no log line. It is the least visible way a healthy-looking service stops working.
Its own type because the right response is specific. This does not mean the message was bad, and it does not mean the connection is broken; it means the broker is under pressure and an operator needs to know. Retrying immediately makes it worse. Backing off, shedding load, or alerting are all reasonable; treating it as an ordinary publish failure is not.
Whether the message reached the broker depends on when the block was noticed, and
mayHaveBeenPublished() says which case this is. RabbitMQ does not announce an alarm
to an idle connection: it tells a connection it is blocked only when that connection next
publishes. So the first message sent into an alarm is written to the socket and then waits for
a confirm that may never come, while every message after it is refused before anything is
written. The first is uncertain; the rest certainly did not arrive.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionConnectionBlockedException(String message, String reason) Nothing was sent: the connection was already known to be blocked.ConnectionBlockedException(String message, String reason, boolean mayHaveBeenPublished) -
Method Summary
Modifier and TypeMethodDescriptionbooleanWhether this message might already be at the broker.reason()Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
ConnectionBlockedException
Nothing was sent: the connection was already known to be blocked.- Parameters:
message- what happened and for how longreason- the broker's own explanation, such aslow on memory
-
ConnectionBlockedException
- Parameters:
message- what happened and for how longreason- the broker's own explanation, such aslow on memorymayHaveBeenPublished- whether the message had already been written to the connection when the block was discovered
-
-
Method Details
-
mayHaveBeenPublished
public boolean mayHaveBeenPublished()Whether this message might already be at the broker.falsemeans it certainly is not, and resending it is safe.truemeans it was written to the connection but never confirmed, so it may have arrived, may have been dropped, and may still arrive — the ordinary at-least-once situation, and the reason consumers need to be idempotent.- Returns:
- whether the message may have reached the broker despite this failure
-
reason
- Returns:
- why the broker said it was blocking, in its own words. RabbitMQ sends
low on memoryorlow on disk, which is the difference between adding consumers and adding disk
-