Class ConnectionBlockedException

All Implemented Interfaces:
Serializable

public class ConnectionBlockedException extends TransportException
The broker has stopped accepting publishes, and waiting for it to resume ran out of time.

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 Details

    • ConnectionBlockedException

      public ConnectionBlockedException(String message, String reason)
      Nothing was sent: the connection was already known to be blocked.
      Parameters:
      message - what happened and for how long
      reason - the broker's own explanation, such as low on memory
    • ConnectionBlockedException

      public ConnectionBlockedException(String message, String reason, boolean mayHaveBeenPublished)
      Parameters:
      message - what happened and for how long
      reason - the broker's own explanation, such as low on memory
      mayHaveBeenPublished - 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.

      false means it certainly is not, and resending it is safe. true means 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

      public String reason()
      Returns:
      why the broker said it was blocking, in its own words. RabbitMQ sends low on memory or low on disk, which is the difference between adding consumers and adding disk