Fix duplicated notification

Now when the pooling is enabled, notification will be triggered two
times because the subscription controller of pooling is also in the
pipeline. This patch fixes it by checking the subscription controller
type.

Closes-Bug: #1489686

Change-Id: I55c72e3869e9b0490bcab3bcae571946bda65aa5
This commit is contained in:
Fei Long Wang 2015-08-28 15:17:59 +12:00
parent 8ce9d3eaef
commit 381ec25698
1 changed files with 6 additions and 4 deletions

View File

@ -19,6 +19,8 @@ import futurist
from oslo_log import log as logging
from six.moves import urllib_parse
from zaqar.storage import pooling
LOG = logging.getLogger(__name__)
@ -34,19 +36,19 @@ class NotifierDriver(object):
def post(self, queue_name, messages, client_uuid, project=None):
"""Send messages to the subscribers."""
if self.subscription_controller:
if (self.subscription_controller and
not isinstance(self.subscription_controller,
pooling.SubscriptionController)):
subscribers = self.subscription_controller.list(queue_name,
project)
for sub in next(subscribers):
s_type = urllib_parse.urlparse(sub['subscriber']).scheme
data_driver = self.subscription_controller.driver
conf = (getattr(data_driver, 'conf', None) or
getattr(data_driver, '_conf'))
mgr = driver.DriverManager('zaqar.notification.tasks',
s_type,
invoke_on_load=True)
self.executor.submit(mgr.driver.execute, sub, messages,
conf=conf)
conf=data_driver.conf)
else:
LOG.error('Failed to get subscription controller.')