Skip to content

Commit ac9bcbd

Browse files
committed
Use Producer.auto_declare to declare exchanges as needed
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.
1 parent c7c4263 commit ac9bcbd

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

st2common/st2common/transport/publishers.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,11 @@ def do_publish(connection, channel):
7171
# completely invalidating this ConnectionPool. Also, a ConnectionPool for
7272
# producer does not really solve any problems for us so better to create a
7373
# Producer for each publish.
74-
producer = Producer(channel)
74+
# passing exchange to Producer __init__ allows auto_declare to declare
75+
# anything that's missing (especially useful for tests).
76+
producer = Producer(channel, exchange=exchange)
7577
kwargs = {
7678
"body": payload,
77-
"exchange": exchange,
7879
"routing_key": routing_key,
7980
"serializer": "pickle",
8081
"compression": compression,

0 commit comments

Comments
 (0)