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
| Name | Type | Description |
|---|---|---|
| queues | Iterable = null | Initial list, tuple, or dict of queues to populate the mapping. |
| default_exchange | Exchange = null | The default exchange to use for queues that do not specify one. |
| create_missing | bool = true | If true, unknown queues are added automatically; otherwise, a KeyError is raised. |
| create_missing_queue_type | str = null | The type of queue to create for missing entries (e.g., 'classic' or 'quorum'). |
| create_missing_queue_exchange_type | str = null | The exchange type to use when creating missing queues. |
| autoexchange | Any = null | The exchange class or factory used for automatic exchange creation. |
| max_priority | int = null | Default x-max-priority value for queues that do not have one set. |
| default_routing_key | str = null | The 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
| Name | Type | Description |
|---|---|---|
| queue | `kombu.Queue | str` |
| exchange | `kombu.Exchange | str` |
| routing_key | str | The binding key to use if the queue is provided as a string. |
| exchange_type | str | The type of exchange to create if the queue is provided as a string. |
Returns
| Type | Description |
|---|---|
kombu.Queue | The 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
| Name | Type | Description |
|---|---|---|
| name | str | The name of the queue to create. |
| **options | Any | Configuration options such as routing_key, binding_key, and exchange settings. |
Returns
| Type | Description |
|---|---|
kombu.Queue | The 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
| Name | Type | Description |
|---|---|---|
| indent | int | The number of spaces to indent the formatted output. |
| indent_first | bool | Whether to apply the indentation to the first line of the output. |
Returns
| Type | Description |
|---|---|
str | A 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
| Name | Type | Description |
|---|---|---|
| queue | `kombu.Queue | str` |
Returns
| Type | Description |
|---|---|
kombu.Queue | The 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
| Name | Type | Description |
|---|---|---|
| include | `Sequence[str] | str` |
Returns
| Type | Description |
|---|---|
null |
deselect()
@classmethod
def deselect(
exclude: Sequence[str]| str
) - > null
Deselect queues so that they won't be consumed from.
Parameters
| Name | Type | Description |
|---|---|---|
| exclude | `Sequence[str] | str` |
Returns
| Type | Description |
|---|---|
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
| Name | Type | Description |
|---|---|---|
| name | str | The name of the queue to be created. |
Returns
| Type | Description |
|---|---|
kombu.Queue | A 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
| Type | Description |
|---|---|
dict | A mapping of queue names to Queue instances that are active for consumption. |