forked from ansible/awx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add the ability to disable RabbitMQ queue durability
- Loading branch information
1 parent
8c56d1d
commit 40b1e89
Showing
9 changed files
with
66 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from amqp.exceptions import PreconditionFailed | ||
from django.conf import settings | ||
from kombu.connection import Connection as KombuConnection | ||
from kombu.transport import pyamqp | ||
|
||
import logging | ||
|
||
logger = logging.getLogger('awx.main.dispatch') | ||
|
||
|
||
__all__ = ['Connection'] | ||
|
||
|
||
class Connection(KombuConnection): | ||
|
||
def __init__(self, *args, **kwargs): | ||
super(Connection, self).__init__(*args, **kwargs) | ||
class _Channel(pyamqp.Channel): | ||
|
||
def queue_declare(self, queue, *args, **kwargs): | ||
kwargs['durable'] = settings.BROKER_DURABILITY | ||
try: | ||
return super(_Channel, self).queue_declare(queue, *args, **kwargs) | ||
except PreconditionFailed as e: | ||
if "inequivalent arg 'durable'" in getattr(e, 'reply_text', None): | ||
logger.error( | ||
'queue {} durability is not {}, deleting and recreating'.format( | ||
|
||
queue, | ||
kwargs['durable'] | ||
) | ||
) | ||
self.queue_delete(queue) | ||
return super(_Channel, self).queue_declare(queue, *args, **kwargs) | ||
|
||
class _Connection(pyamqp.Connection): | ||
Channel = _Channel | ||
|
||
class _Transport(pyamqp.Transport): | ||
Connection = _Connection | ||
|
||
self.transport_cls = _Transport |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters