Ensures listener queues exist in fake driver
The fanout queues of the fake driver are created at the first executor poll, but if we use eventlet executor and the fake driver, when the sender delivers a fanout message before the first poll, the message goes to the topic queue instead of the server fanout queue. The changes fixes that by ensuring the all queues exists when the listener is created. Closes bug #1331453 Related-Bug: #1334798 Co-authored-by: Paul Michali <pcm@cisco.com> Change-Id: I92e7c01dd87d634b741bbcaea92f48730fdd555e (cherry picked from commite582da68f4
) (cherry picked from commit0cfafac246
)
This commit is contained in:
parent
c21a2c22b3
commit
d822f6cbf0
|
@ -45,6 +45,12 @@ class FakeListener(base.Listener):
|
|||
self._exchange_manager = exchange_manager
|
||||
self._targets = targets
|
||||
|
||||
# NOTE(sileht): Ensure that all needed queues exists even the listener
|
||||
# have not been polled yet
|
||||
for target in self._targets:
|
||||
exchange = self._exchange_manager.get_exchange(target.exchange)
|
||||
exchange.ensure_queue(target)
|
||||
|
||||
def poll(self):
|
||||
while True:
|
||||
for target in self._targets:
|
||||
|
@ -65,6 +71,13 @@ class FakeExchange(object):
|
|||
self._topic_queues = {}
|
||||
self._server_queues = {}
|
||||
|
||||
def ensure_queue(self, target):
|
||||
with self._queues_lock:
|
||||
if target.server:
|
||||
self._get_server_queue(target.topic, target.server)
|
||||
else:
|
||||
self._get_topic_queue(target.topic)
|
||||
|
||||
def _get_topic_queue(self, topic):
|
||||
return self._topic_queues.setdefault(topic, [])
|
||||
|
||||
|
|
Loading…
Reference in New Issue