FakeProducer
faststream.rabbit.test.FakeProducer #
Bases: AioPikaFastProducer
A fake RabbitMQ producer for testing purposes.
This class extends AioPikaFastProducer and is used to simulate RabbitMQ message publishing during tests.
Initialize a FakeProducer instance.
PARAMETER | DESCRIPTION |
---|---|
broker | The RabbitBroker instance to be used for message publishing. TYPE: |
Source code in faststream/rabbit/test.py
publish async
#
publish(
message: AioPikaSendableMessage = "",
queue: Union[RabbitQueue, str] = "",
exchange: Union[RabbitExchange, str, None] = None,
*,
routing_key: str = "",
mandatory: bool = True,
immediate: bool = False,
timeout: TimeoutType = None,
rpc: bool = False,
rpc_timeout: Optional[float] = 30.0,
raise_timeout: bool = False,
persist: bool = False,
reply_to: Optional[str] = None,
**message_kwargs: Any
) -> Optional[SendableMessage]
Publish a message to a RabbitMQ queue or exchange.
PARAMETER | DESCRIPTION |
---|---|
message | The message to be published. TYPE: |
queue | The target queue for the message. TYPE: |
exchange | The target exchange for the message. TYPE: |
routing_key | The routing key for the message. TYPE: |
mandatory | Whether the message is mandatory. TYPE: |
immediate | Whether the message should be sent immediately. TYPE: |
timeout | The timeout for the message. TYPE: |
rpc | Whether the message is for RPC. TYPE: |
rpc_timeout | The RPC timeout. TYPE: |
raise_timeout | Whether to raise a timeout exception. TYPE: |
persist | Whether to persist the message. TYPE: |
reply_to | The reply-to address for RPC messages. TYPE: |
**message_kwargs | Additional message properties and content. TYPE: |
RETURNS | DESCRIPTION |
---|---|
Optional[SendableMessage] | Optional[SendableMessage]: The published message if successful, or None if not. |
Source code in faststream/rabbit/test.py
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 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 |
|