Delete fanout queues on gracefully shutdown

No reasons to kept fanout queues in case then
a rpc server is gracefully shutdown. The expiration
time of the fanout queue is too long (30 mins), so for
large scales it can accumulate a lot of messages before it be removed

Closes-Bug: 1606213
Change-Id: Ieaa35c454df542042f3a5424d70f87d486693024
This commit is contained in:
Kirill Bespalov 2016-07-25 15:11:53 +03:00 committed by kbespalov
parent 0ecc25509f
commit a6f0aaed3f
1 changed files with 5 additions and 1 deletions

View File

@ -844,6 +844,11 @@ class Connection(object):
"""Close/release this connection."""
self._heartbeat_stop()
if self.connection:
for consumer, tag in self._consumers.items():
if consumer.type == 'fanout':
LOG.debug('[connection close] Deleting fanout '
'queue: %s ' % consumer.queue.name)
consumer.queue.delete()
self._set_current_channel(None)
self.connection.release()
self.connection = None
@ -852,7 +857,6 @@ class Connection(object):
"""Reset a connection so it can be used again."""
recoverable_errors = (self.connection.recoverable_channel_errors +
self.connection.recoverable_connection_errors)
with self._connection_lock:
try:
for consumer, tag in self._consumers.items():