QUEUES¶
To declare a Queue with all parameters in Propan, a special class propan.brokers.rabbit.RabbitQueue is used.
You can use it both when receiving messages and sending them:
from propan.brokers.rabbit import RabbitBroker, RabbitQueue
broker = RabbitBroker()
@broker.handler(RabbitQueue("test"))
asynchronous definition handler():
...
...
await broker.publish("Hi!", RabbitQueue("test"))
The RabbitQueue constructor takes the following arguments:
name: str - queue namedurable: bool = False - if set to True, restore queue at RabbitMQ restartedauto_delete: bool = False - if set to True, delete queue with RabbitMQ disconnectedexclusive: bool = False - this queue can only be connected within the current connection. Such a queue will also be deleted when disconnected from RabbitMQ.passive: bool = False- when set to
False, Propan will attempt to create a queue with the required parameters, or check those parameters to match an already existing queue with the same name. - when set to
True, Propan will not create a queue, but only connect to an existing one. In this case, if the requested queue does not exist, an error will occur.
- when set to
robust: bool = True - recreate the queue when reconnecting to RabbitMQtimeout: int | float - response timeout from RabbitMQarguments: dict[str, Any] | None = None - custom queue arguments
The parameters for connecting the queue to exchange are also passed in its constructor:
routing_key: str - routing key for connecting to exchange. If not specified, thenameargument is usedbind_arguments: dict[str, Any] | None = None - arguments to header exchange routing