RabbitRouter
faststream.rabbit.RabbitRouter #
RabbitRouter(
prefix: str = "",
handlers: Sequence[RabbitRoute] = (),
*,
dependencies: Sequence[Depends] = (),
middlewares: Optional[
Sequence[
Callable[
[aio_pika.IncomingMessage], BaseMiddleware
]
]
] = None,
parser: Optional[
CustomParser[
aio_pika.IncomingMessage, RabbitMessage
]
] = None,
decoder: Optional[CustomDecoder[RabbitMessage]] = None
)
Bases: RabbitRouter
A class representing a RabbitMQ router for publishing messages.
METHOD | DESCRIPTION |
---|---|
_get_publisher_key | Returns the key for a given Publisher object |
_update_publisher_prefix | Updates the prefix of a given Publisher object |
publisher | Publishes a message to RabbitMQ |
Note
The above docstring is autogenerated by docstring-gen library (https://docstring-gen.airt.ai)
Source code in faststream/rabbit/router.py
include_router #
Includes a router in the current object.
PARAMETER | DESCRIPTION |
---|---|
router | The router to be included. TYPE: |
RETURNS | DESCRIPTION |
---|---|
None | None |
Note
The above docstring is autogenerated by docstring-gen library (https://docstring-gen.airt.ai)
Source code in faststream/broker/router.py
include_routers #
Includes routers in the object.
PARAMETER | DESCRIPTION |
---|---|
*routers | Variable length argument list of routers to include. TYPE: |
RETURNS | DESCRIPTION |
---|---|
None | None |
Note
The above docstring is autogenerated by docstring-gen library (https://docstring-gen.airt.ai)
Source code in faststream/broker/router.py
publisher #
publisher(
queue: Union[RabbitQueue, str] = "",
exchange: Union[RabbitExchange, str, None] = None,
*,
routing_key: str = "",
mandatory: bool = True,
immediate: bool = False,
timeout: TimeoutType = None,
persist: bool = False,
reply_to: Optional[str] = None,
title: Optional[str] = None,
description: Optional[str] = None,
schema: Optional[Any] = None,
priority: Optional[int] = None,
**message_kwargs: Any
) -> Publisher
Publishes a message to a RabbitMQ queue or exchange.
PARAMETER | DESCRIPTION |
---|---|
queue | The RabbitMQ queue to publish the message to. Can be either a RabbitQueue object or a string representing the queue name. TYPE: |
exchange | The RabbitMQ exchange to publish the message to. Can be either a RabbitExchange object, a string representing the exchange name, or None. TYPE: |
routing_key | The routing key to use when publishing the message. TYPE: |
mandatory | Whether the message is mandatory or not. TYPE: |
immediate | Whether the message should be delivered immediately or not. TYPE: |
timeout | The timeout for the publish operation. TYPE: |
persist | Whether the message should be persisted or not. TYPE: |
reply_to | The reply-to address for the message. |
title | The title of the message (AsyncAPI information). |
description | The description of the message (AsyncAPI information). |
**message_kwargs | Additional keyword arguments to include in the message. TYPE: |
RETURNS | DESCRIPTION |
---|---|
Publisher | The Publisher object used to publish the message. |
Note
The above docstring is autogenerated by docstring-gen library (https://docstring-gen.airt.ai)
Source code in faststream/rabbit/router.py
subscriber #
subscriber(
queue: Union[str, RabbitQueue],
exchange: Union[str, RabbitExchange, None] = None,
*,
consume_args: Optional[AnyDict] = None,
dependencies: Sequence[Depends] = (),
filter: Filter[RabbitMessage] = default_filter,
parser: Optional[
CustomParser[
aio_pika.IncomingMessage, RabbitMessage
]
] = None,
decoder: Optional[CustomDecoder[RabbitMessage]] = None,
middlewares: Optional[
Sequence[
Callable[
[aio_pika.IncomingMessage], BaseMiddleware
]
]
] = None,
retry: Union[bool, int] = False,
title: Optional[str] = None,
description: Optional[str] = None,
**__service_kwargs: Any
) -> Callable[
[Callable[P_HandlerParams, T_HandlerReturn]],
HandlerCallWrapper[
aio_pika.IncomingMessage,
P_HandlerParams,
T_HandlerReturn,
],
]