Skip to content

Commit

Permalink
Suggest ContextVar to find message for ConfirmationFrame asynchrono…
Browse files Browse the repository at this point in the history
…usly.
  • Loading branch information
MaPePeR committed May 30, 2023
1 parent 0dd4f27 commit 3cbb22d
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions docs/source/rabbitmq-tutorial/7-publisher-confirms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,14 @@ The broker confirms published messages asynchronously, one just needs to registe
The `.result()` method will either return a `aiormq.abc.ConfirmationFrameType` for confirmed messages
or raise an Exception for nack-ed messages (messages that can be considered lost by the broker).

..
TODO: Which exceptions can be raised?
How to determine which message the callback belongs to?
From RabbitMQ Tutorial:
Each callback has AMQPMessage $message parameter with returned message, so you don't need to handle sequence numbers (delivery tag) to understand which message this callback belongs to.
The callback does not have the `Message` that corresponds to the `ConfirmationFrame` that is returned by `.result()` or
contained in the `DeliveryError`.
You can use sequence numbers (delivery tag) to understand which message this callback belongs to or retrieve additional
information using a `ContextVar`_.
The `TimeoutError` does not contain a `ConfirmationFrame`, so a `ContextVar` is required to get additional information
about the message that triggered the timeout.

.. _ContextVar: https://docs.python.org/3/library/contextvars.html#contextvars.ContextVar

Summary
+++++++
Expand Down

0 comments on commit 3cbb22d

Please sign in to comment.