Skip to main content

Queues

Queue name⇒ declaration mapping.

Constructor​

Signature​

def Queues(
queues: Iterable = null,
default_exchange: Exchange = null,
create_missing: bool = true,
create_missing_queue_type: str = null,
create_missing_queue_exchange_type: str = null,
autoexchange: Any = null,
max_priority: int = null,
default_routing_key: str = null
) - > null

Parameters​

NameTypeDescription
queuesIterable = nullInitial list, tuple, or dict of queues to populate the mapping.
default_exchangeExchange = nullThe default exchange to use for queues that do not specify one.
create_missingbool = trueIf true, unknown queues are added automatically; otherwise, a KeyError is raised.
create_missing_queue_typestr = nullThe type of queue to create for missing entries (e.g., 'classic' or 'quorum').
create_missing_queue_exchange_typestr = nullThe exchange type to use when creating missing queues.
autoexchangeAny = nullThe exchange class or factory used for automatic exchange creation.
max_priorityint = nullDefault x-max-priority value for queues that do not have one set.
default_routing_keystr = nullThe default routing key to use for queues.

Methods​


add()​

@classmethod
def add(
queue: kombu.Queue | str,
exchange: kombu.Exchange | str,
routing_key: str,
exchange_type: str
) - > kombu.Queue

Add new queue. The first argument can either be a :class:kombu.Queue instance, or the name of a queue.

Parameters​

NameTypeDescription
queue`kombu.Queuestr`
exchange`kombu.Exchangestr`
routing_keystrThe binding key to use if the queue is provided as a string.
exchange_typestrThe type of exchange to create if the queue is provided as a string.

Returns​

TypeDescription
kombu.QueueThe queue instance that was added to the collection.

add_compat()​

@classmethod
def add_compat(
name: str,
**options: Any
) - > kombu.Queue

Adds a queue using a dictionary-like interface for backward compatibility, ensuring routing keys are properly defaulted.

Parameters​

NameTypeDescription
namestrThe name of the queue to create.
**optionsAnyConfiguration options such as routing_key, binding_key, and exchange settings.

Returns​

TypeDescription
kombu.QueueThe queue instance created and added from the provided options.

format()​

@classmethod
def format(
indent: int,
indent_first: bool
) - > str

Format routing table into string for log dumps.

Parameters​

NameTypeDescription
indentintThe number of spaces to indent the formatted output.
indent_firstboolWhether to apply the indentation to the first line of the output.

Returns​

TypeDescription
strA formatted string representing the active queues and their configurations.

select_add()​

@classmethod
def select_add(
queue: kombu.Queue | str
) - > kombu.Queue

Add new task queue that'll be consumed from. The queue will be active even when a subset has been selected.

Parameters​

NameTypeDescription
queue`kombu.Queuestr`

Returns​

TypeDescription
kombu.QueueThe queue instance that was added and marked for consumption.

select()​

@classmethod
def select(
include: Sequence[str]| str
) - > null

Select a subset of currently defined queues to consume from.

Parameters​

NameTypeDescription
include`Sequence[str]str`

Returns​

TypeDescription
null

deselect()​

@classmethod
def deselect(
exclude: Sequence[str]| str
) - > null

Deselect queues so that they won't be consumed from.

Parameters​

NameTypeDescription
exclude`Sequence[str]str`

Returns​

TypeDescription
null

new_missing()​

@classmethod
def new_missing(
name: str
) - > kombu.Queue

Creates a new Queue instance for a missing name using the configured default queue and exchange types.

Parameters​

NameTypeDescription
namestrThe name of the queue to be created.

Returns​

TypeDescription
kombu.QueueA new Queue instance configured with the specified name and default settings.

consume_from()​

@classmethod
def consume_from() - > dict

Returns the subset of queues currently selected for consumption, or all queues if no subset is defined.

Returns​

TypeDescription
dictA mapping of queue names to Queue instances that are active for consumption.