Exception Classes

The following exceptions should be raised by your code in your Consumer code. See the consumers. documentation for more information.

class rejected.errors.ConsumerException(value=None, metric=None, *args, **kwargs)[source]

May be called when processing a message to indicate a problem that the Consumer may be experiencing that should cause it to stop.

Changed in version 3.19.0.

Parameters:
  • value (str) – An optional value used in string representation
  • metric (str) – An optional value for auto-instrumentation of exceptions
class rejected.errors.MessageException(value=None, metric=None, *args, **kwargs)[source]

Invoke when a message should be rejected and not re-queued, but not due to a processing error that should cause the consumer to stop.

Changed in version 3.19.0.

Parameters:
  • value (str) – An optional value used in string representation
  • metric (str) – An optional value for auto-instrumentation of exceptions
class rejected.errors.ProcessingException(value=None, metric=None, *args, **kwargs)[source]

Invoke when a message should be rejected and not re-queued, but not due to a processing error that should cause the consumer to stop. This should be used for when you want to reject a message which will be republished to a retry queue, without anything being stated about the exception.

Changed in version 3.19.0.

Parameters:
  • value (str) – An optional value used in string representation
  • metric (str) – An optional value for auto-instrumentation of exceptions

Other Exceptions

These exceptions should not be raised directly by your code.

class rejected.errors.RejectedException(value=None, metric=None, *args, **kwargs)[source]

Base exception for Consumer related exceptions.

If provided, the metric will be used to automatically record exception metric counts using the path [prefix].[consumer-name].exceptions.[exception-type].[metric].

Positional and keyword arguments are used to format the value that is passed in when providing the string value of the exception.

New in version 3.19.0.

Parameters:
  • value (str) – An optional value used in string representation
  • metric (str) – An optional value for auto-instrumentation of exceptions
class rejected.errors.RabbitMQException(connection, error_code, error_text, *args, **kwargs)[source]

Raised when an error sent from RabbitMQ, closing the channel. When the channel is closed, no more AMQP operations may be performed by the consumer for the current message. In addition, if the connection is configured with no_ack set to False, the message is returned to the queue.

New in version 4.0.0.

class rejected.errors.ConfigurationException(value=None, metric=None, *args, **kwargs)[source]

Raised when require_setting is invoked and the specified setting was not configured. When raised, the consumer will shutdown.

New in version 4.0.0.

class rejected.errors.ExecutionFinished[source]

Invoked by rejected.consumer.Consumer.finish to abort further processing of a message.

New in version 4.0.0.

class rejected.errors.DropMessage[source]

Invoked during rejected.consumer.Consumer._preprocessing if the message needs to be dropped.

New in version 4.0.0.