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 Change-Id: I92e7c01dd87d634b741bbcaea92f48730fdd555e
This commit is contained in:
parent
821ee096a6
commit
e582da68f4
|
@ -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, timeout=None):
|
||||
if timeout is not None:
|
||||
deadline = time.time() + timeout
|
||||
|
@ -77,6 +83,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