RabbitRouter
faststream.rabbit.RabbitRouter #
RabbitRouter(
prefix="",
handlers=(),
*,
dependencies=(),
middlewares=(),
parser=None,
decoder=None,
include_in_schema=None,
)
Bases: RabbitRegistrator
, BrokerRouter['IncomingMessage']
Includable to RabbitBroker router.
Source code in faststream/rabbit/router.py
add_middleware #
Append BrokerMiddleware to the end of middlewares list.
Current middleware will be used as a most inner of already existed ones.
Source code in faststream/broker/core/abc.py
subscriber #
subscriber(
queue,
exchange=None,
*,
consume_args=None,
dependencies=(),
parser=None,
decoder=None,
middlewares=(),
channel=None,
reply_config=None,
filter=default_filter,
retry=False,
no_ack=False,
no_reply=False,
title=None,
description=None,
include_in_schema=True,
)
Declares RabbitMQ subscriber object and binds it to the exchange.
You can use it as a handler decorator - @broker.subscriber(...)
. Or you can create a subscriber object to call it lately - broker.subscriber(...)
.
PARAMETER | DESCRIPTION |
---|---|
queue | RabbitMQ queue to listen. FastStream declares and binds TYPE: |
exchange | RabbitMQ exchange to bind queue to. Uses default exchange TYPE: |
consume_args | Extra consumer arguments to use in TYPE: |
channel | Channel to use for consuming messages. If not specified, a default channel will be used. |
reply_config | Extra options to use at replies publishing. TYPE: |
dependencies | Dependencies list ( TYPE: |
parser | Parser to map original IncomingMessage Msg to FastStream one. TYPE: |
decoder | Function to decode FastStream msg bytes body to python objects. TYPE: |
middlewares | Subscriber middlewares to wrap incoming message processing. TYPE: |
filter | Overload subscriber to consume various messages from the same source. TYPE: |
retry | Whether to |
no_ack | Whether to disable FastStream autoacknowledgement logic or not. TYPE: |
no_reply | Whether to disable FastStream RPC and Reply To auto responses or not. TYPE: |
title | AsyncAPI subscriber object title. |
description | AsyncAPI subscriber object description. Uses decorated docstring as default. |
include_in_schema | Whether to include operation in AsyncAPI schema or not. TYPE: |
Source code in faststream/rabbit/broker/registrator.py
publisher #
publisher(
queue="",
exchange=None,
*,
routing_key="",
mandatory=True,
immediate=False,
timeout=None,
persist=False,
reply_to=None,
priority=None,
middlewares=(),
title=None,
description=None,
schema=None,
include_in_schema=True,
headers=None,
content_type=None,
content_encoding=None,
expiration=None,
message_type=None,
user_id=None,
)
Creates long-living and AsyncAPI-documented publisher object.
You can use it as a handler decorator (handler should be decorated by @broker.subscriber(...)
too) - @broker.publisher(...)
. In such case publisher will publish your handler return value.
Or you can create a publisher object to call it lately - broker.publisher(...).publish(...)
.
PARAMETER | DESCRIPTION |
---|---|
queue | Default message routing key to publish with. TYPE: |
exchange | Target exchange to publish message to. TYPE: |
routing_key | Default message routing key to publish with. TYPE: |
mandatory | Client waits for confirmation that the message is placed to some queue. RabbitMQ returns message to client if there is no suitable queue. TYPE: |
immediate | Client expects that there is a consumer ready to take the message to work. RabbitMQ returns message to client if there is no suitable consumer. TYPE: |
timeout | Send confirmation time from RabbitMQ. TYPE: |
persist | Restore the message on RabbitMQ reboot. TYPE: |
reply_to | Reply message routing key to send with (always sending to default exchange). |
priority | The message priority (0 by default). |
middlewares | Publisher middlewares to wrap outgoing messages. TYPE: |
title | AsyncAPI publisher object title. |
description | AsyncAPI publisher object description. |
schema | AsyncAPI publishing message type. Should be any python-native object annotation or |
include_in_schema | Whether to include operation in AsyncAPI schema or not. TYPE: |
headers | Message headers to store meta-information. Can be overridden by TYPE: |
content_type | Message content-type header. Used by application, not core RabbitMQ. Will be set automatically if not specified. |
content_encoding | Message body content encoding, e.g. gzip. |
expiration | Message expiration (lifetime) in seconds (or datetime or timedelta). TYPE: |
message_type | Application-specific message type, e.g. orders.created. |
user_id | Publisher connection User ID, validated if set. |
Source code in faststream/rabbit/broker/registrator.py
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
|