Skip to content

RabbitRoute

faststream.rabbit.broker.router.RabbitRoute #

RabbitRoute(
    call,
    queue,
    exchange=None,
    *,
    publishers=(),
    consume_args=None,
    dependencies=(),
    parser=None,
    decoder=None,
    middlewares=(),
    no_ack=EMPTY,
    ack_policy=EMPTY,
    no_reply=False,
    title=None,
    description=None,
    include_in_schema=True,
)

Bases: SubscriberRoute

Class to store delayed RabbitBroker subscriber registration.

Just a copy of RabbitRegistrator.subscriber(...) arguments.

Initialized RabbitRoute.

PARAMETER DESCRIPTION
call

Message handler function to wrap the same with @broker.subscriber(...) way.

TYPE: Callable[..., AioPikaSendableMessage] | Callable[..., Awaitable[AioPikaSendableMessage]]

queue

RabbitMQ queue to listen. FastStream declares and binds queue object to exchange automatically by default.

TYPE: Union[str, RabbitQueue]

exchange

RabbitMQ exchange to bind queue to. Uses default exchange if not present. FastStream declares exchange object automatically by default.

TYPE: Union[str, RabbitExchange, None] DEFAULT: None

publishers

RabbitMQ publishers to broadcast the handler result.

TYPE: Iterable[RabbitPublisher] DEFAULT: ()

consume_args

Extra consumer arguments to use in queue.consume(...) method.

TYPE: dict[str, Any] | None DEFAULT: None

dependencies

Dependencies list ([Dependant(),]) to apply to the subscriber.

TYPE: Iterable[Dependant] DEFAULT: ()

parser

Parser to map original IncomingMessage Msg to FastStream one.

TYPE: Optional[CustomCallable] DEFAULT: None

decoder

Function to decode FastStream msg bytes body to python objects.

TYPE: Optional[CustomCallable] DEFAULT: None

middlewares

Subscriber middlewares to wrap incoming message processing.

TYPE: Sequence[SubscriberMiddleware[Any]] DEFAULT: ()

no_ack

Whether to disable FastStream auto acknowledgement logic or not. Scheduled to remove in 0.7.0

TYPE: bool DEFAULT: EMPTY

ack_policy

Acknowledgment policy for the subscriber (by default MANUAL).

TYPE: AckPolicy DEFAULT: EMPTY

no_reply

Whether to disable FastStream RPC and Reply To auto responses or not.

TYPE: bool DEFAULT: False

title

AsyncAPI subscriber object title.

TYPE: str | None DEFAULT: None

description

AsyncAPI subscriber object description. Uses decorated docstring as default.

TYPE: str | None DEFAULT: None

include_in_schema

Whetever to include operation in AsyncAPI schema or not.

TYPE: bool DEFAULT: True

Source code in faststream/rabbit/broker/router.py
def __init__(
    self,
    call: Callable[..., "AioPikaSendableMessage"]
    | Callable[..., Awaitable["AioPikaSendableMessage"]],
    queue: Union[str, "RabbitQueue"],
    exchange: Union[str, "RabbitExchange", None] = None,
    *,
    publishers: Iterable[RabbitPublisher] = (),
    consume_args: dict[str, Any] | None = None,
    # broker arguments
    dependencies: Iterable["Dependant"] = (),
    parser: Optional["CustomCallable"] = None,
    decoder: Optional["CustomCallable"] = None,
    middlewares: Annotated[
        Sequence["SubscriberMiddleware[Any]"],
        deprecated(
            "This option was deprecated in 0.6.0. Use router-level middlewares instead."
            "Scheduled to remove in 0.7.0",
        ),
    ] = (),
    no_ack: Annotated[
        bool,
        deprecated(
            "This option was deprecated in 0.6.0 to prior to **ack_policy=AckPolicy.MANUAL**. "
            "Scheduled to remove in 0.7.0",
        ),
    ] = EMPTY,
    ack_policy: AckPolicy = EMPTY,
    no_reply: bool = False,
    # AsyncAPI information
    title: str | None = None,
    description: str | None = None,
    include_in_schema: bool = True,
) -> None:
    """Initialized RabbitRoute.

    Args:
        call:
            Message handler function
            to wrap the same with `@broker.subscriber(...)` way.
        queue:
            RabbitMQ queue to listen.
            **FastStream** declares and binds queue object to `exchange` automatically by default.
        exchange:
            RabbitMQ exchange to bind queue to.
            Uses default exchange if not present.
            **FastStream** declares exchange object automatically by default.
        publishers:
            RabbitMQ publishers to broadcast the handler result.
        consume_args:
            Extra consumer arguments to use in `queue.consume(...)` method.
        dependencies:
            Dependencies list (`[Dependant(),]`) to apply to the subscriber.
        parser:
            Parser to map original **IncomingMessage** Msg to FastStream one.
        decoder:
            Function to decode FastStream msg bytes body to python objects.
        middlewares:
            Subscriber middlewares to wrap incoming message processing.
        no_ack:
            Whether to disable **FastStream** auto acknowledgement logic or not.
            Scheduled to remove in 0.7.0
        ack_policy:
            Acknowledgment policy for the subscriber (by default `MANUAL`).
        no_reply:
            Whether to disable **FastStream** RPC and Reply To auto responses or not.
        title:
            AsyncAPI subscriber object title.
        description:
            AsyncAPI subscriber object description.
            Uses decorated docstring as default.
        include_in_schema:
            Whetever to include operation in AsyncAPI schema or not.
    """
    super().__init__(
        call,
        publishers=publishers,
        queue=queue,
        exchange=exchange,
        consume_args=consume_args,
        dependencies=dependencies,
        parser=parser,
        decoder=decoder,
        middlewares=middlewares,
        ack_policy=ack_policy,
        no_ack=no_ack,
        no_reply=no_reply,
        title=title,
        description=description,
        include_in_schema=include_in_schema,
    )

args instance-attribute #

args = args

kwargs instance-attribute #

kwargs = kwargs

call instance-attribute #

call = call

publishers instance-attribute #

publishers = publishers