Skip to content

Commit

Permalink
Use Producer.auto_declare to declare exchanges as needed
Browse files Browse the repository at this point in the history
Connection has a cache of which entities (exchange/queue)
have been declared, so this shouldn't have too much of a
performance impact. This does, however, make tests much more
reliable.
  • Loading branch information
cognifloyd committed Nov 12, 2024
1 parent ee3173a commit 07f855d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion st2common/st2common/transport/publishers.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ def do_publish(connection, channel):
# completely invalidating this ConnectionPool. Also, a ConnectionPool for
# producer does not really solve any problems for us so better to create a
# Producer for each publish.
producer = Producer(channel)
# passing exchange to Producer __init__ allows auto_declare to declare
# anything that's missing (especially useful for tests).
producer = Producer(channel, exchange=exchange)
kwargs = {
"body": payload,
"exchange": exchange,
Expand Down

0 comments on commit 07f855d

Please sign in to comment.