Add rabbit_durable_queues config option.

Fixes bug 1054183

Avoid AMQPChannelException: (406, "PRECONDITION_FAILED...") failures
due to a mismatch between the durability of rabbitmq exchange/queue
declared by glance and ceilometer.

Change-Id: I4e25986a1f503782e701aa1168c4eb231ff25d06
This commit is contained in:
Eoghan Glynn 2012-09-21 15:32:49 +00:00
parent 7b84172830
commit 5268d6b1a7
3 changed files with 12 additions and 3 deletions

View File

@ -795,6 +795,12 @@ Optional. Default: ``30``
Maximum seconds to wait before reconnecting on failures when using
``rabbit`` strategy.
* ``rabbit_durable_queues``
Optional. Default: ``False``
Controls durability of exchange and queue when using ``rabbit`` strategy.
* ``qpid_notification_exchange``
Optional. Default: ``glance``

View File

@ -149,6 +149,7 @@ rabbit_password = guest
rabbit_virtual_host = /
rabbit_notification_exchange = glance
rabbit_notification_topic = glance_notifications
rabbit_durable_queues = False
# Configuration options if sending notifications via Qpid (these are
# the defaults)

View File

@ -38,8 +38,9 @@ rabbit_opts = [
default='glance_notifications'),
cfg.StrOpt('rabbit_max_retries', default=0),
cfg.StrOpt('rabbit_retry_backoff', default=2),
cfg.StrOpt('rabbit_retry_max_backoff', default=30)
]
cfg.StrOpt('rabbit_retry_max_backoff', default=30),
cfg.StrOpt('rabbit_durable_queues', default=False),
]
CONF = cfg.CONF
CONF.register_opts(rabbit_opts)
@ -103,6 +104,7 @@ class RabbitStrategy(strategy.Strategy):
self.exchange = kombu.entity.Exchange(
channel=self.channel,
type="topic",
durable=CONF.rabbit_durable_queues,
name=CONF.rabbit_notification_exchange)
# NOTE(jerdfelt): Normally the consumer would create the queues,
@ -113,7 +115,7 @@ class RabbitStrategy(strategy.Strategy):
queue = kombu.entity.Queue(
channel=self.channel,
exchange=self.exchange,
durable=True,
durable=CONF.rabbit_durable_queues,
name=routing_key,
routing_key=routing_key)
queue.declare()