RabbitRouter
faststream.rabbit.router.RabbitRouter #
RabbitRouter(
prefix: str = "",
handlers: Sequence[RabbitRoute] = (),
*,
dependencies: Sequence[Depends] = (),
middlewares: Sequence[
Callable[[IncomingMessage], BaseMiddleware]
]
| None = None,
parser: CustomParser[IncomingMessage, RabbitMessage]
| None = None,
decoder: CustomDecoder[RabbitMessage] | None = None,
include_in_schema: bool = True
)
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 |
Source code in faststream/rabbit/router.py
include_router #
include_router(
router: BrokerRouter[PublisherKeyType, MsgType]
) -> None
Includes a router in the current object.
PARAMETER | DESCRIPTION |
---|---|
router | The router to be included. TYPE: |
RETURNS | DESCRIPTION |
---|---|
None | None |
Source code in faststream/broker/router.py
include_routers #
include_routers(
*routers: BrokerRouter[PublisherKeyType, MsgType]
) -> None
Includes routers in the object.
PARAMETER | DESCRIPTION |
---|---|
*routers | Variable length argument list of routers to include. TYPE: |
RETURNS | DESCRIPTION |
---|---|
None | None |
Source code in faststream/broker/router.py
publisher #
publisher(
queue: RabbitQueue | str = "",
exchange: RabbitExchange | str | None = None,
*,
routing_key: str = "",
mandatory: bool = True,
immediate: bool = False,
timeout: TimeoutType = None,
persist: bool = False,
reply_to: str | None = None,
title: str | None = None,
description: str | None = None,
schema: Any | None = None,
include_in_schema: bool = True,
priority: int | None = 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. TYPE: |
title | The title of the message (AsyncAPI information). TYPE: |
description | The description of the message (AsyncAPI information). TYPE: |
schema | The schema of the message (AsyncAPI information). TYPE: |
include_in_schema | Whether to include the message in the API specification (AsyncAPI information). TYPE: |
priority | The priority of the message. TYPE: |
**message_kwargs | Additional keyword arguments to include in the message. TYPE: |
RETURNS | DESCRIPTION |
---|---|
Publisher | The Publisher object used to publish the message. |
Source code in faststream/rabbit/router.py
subscriber #
subscriber(
queue: str | RabbitQueue,
exchange: str | RabbitExchange | None = None,
*,
consume_args: AnyDict | None = None,
reply_config: ReplyConfig | None = None,
dependencies: Sequence[Depends] = (),
filter: Filter[RabbitMessage] = default_filter,
parser: CustomParser[IncomingMessage, RabbitMessage]
| None = None,
decoder: CustomDecoder[RabbitMessage] | None = None,
middlewares: Sequence[
Callable[[IncomingMessage], BaseMiddleware]
]
| None = None,
retry: bool | int = False,
no_ack: bool = False,
title: str | None = None,
description: str | None = None,
include_in_schema: bool = True,
**__service_kwargs: Any
) -> Callable[
[Callable[P_HandlerParams, T_HandlerReturn]],
HandlerCallWrapper[
IncomingMessage, P_HandlerParams, T_HandlerReturn
],
]