Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Add support for heartbeating in the kombu RPC driver
Browse files Browse the repository at this point in the history
This aides in detecting connection interruptions that would otherwise
go unnoticed.

Fixes bug #856764

Change-Id: Id4eb3d36036969b62890175d6a33b4e304be0527
  • Loading branch information
Kiall Mac Innes committed Jul 8, 2013
1 parent bc7e5c8 commit c37f6aa
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
4 changes: 4 additions & 0 deletions openstack/common/rpc/impl_kombu.py
Expand Up @@ -83,6 +83,9 @@
default=0,
help='maximum retries with trying to connect to RabbitMQ '
'(the default of 0 implies an infinite retry count)'),
cfg.IntOpt('rabbit_heartbeat',
default=60,
help='Seconds between connection keepalive heartbeats'),
cfg.BoolOpt('rabbit_durable_queues',
default=False,
help='use durable queues in RabbitMQ'),
Expand Down Expand Up @@ -450,6 +453,7 @@ def __init__(self, conf, server_params=None):
'userid': self.conf.rabbit_userid,
'password': self.conf.rabbit_password,
'virtual_host': self.conf.rabbit_virtual_host,
'heartbeat': self.conf.rabbit_heartbeat,
}

for sp_key, value in server_params.iteritems():
Expand Down
21 changes: 14 additions & 7 deletions tests/unit/rpc/test_kombu.py
Expand Up @@ -362,7 +362,8 @@ def __init__(myself, *args, **kwargs):
'password': FLAGS.rabbit_password,
'port': FLAGS.rabbit_port,
'virtual_host': FLAGS.rabbit_virtual_host,
'transport': 'memory'}])
'transport': 'memory',
'heartbeat': FLAGS.rabbit_heartbeat}])

def topic_send(_context, topic, msg):
pass
Expand All @@ -382,7 +383,8 @@ def test_cast_to_server_uses_server_params(self):
'password': 'fake_password',
'hostname': 'fake_hostname',
'port': 31337,
'virtual_host': 'fake_virtual_host'}
'virtual_host': 'fake_virtual_host',
'heartbeat': FLAGS.rabbit_heartbeat}

class MyConnection(impl_kombu.Connection):
def __init__(myself, *args, **kwargs):
Expand All @@ -394,7 +396,8 @@ def __init__(myself, *args, **kwargs):
'password': server_params['password'],
'port': server_params['port'],
'virtual_host': server_params['virtual_host'],
'transport': 'memory'}])
'transport': 'memory',
'heartbeat': FLAGS.rabbit_heartbeat}])

def topic_send(_context, topic, msg):
pass
Expand Down Expand Up @@ -736,25 +739,29 @@ def test_roundrobin_reconnect(self):
'password': FLAGS.rabbit_password,
'port': 1234,
'virtual_host': FLAGS.rabbit_virtual_host,
'transport': 'memory'},
'transport': 'memory',
'heartbeat': FLAGS.rabbit_heartbeat},
{'hostname': 'host2',
'userid': FLAGS.rabbit_userid,
'password': FLAGS.rabbit_password,
'port': 5678,
'virtual_host': FLAGS.rabbit_virtual_host,
'transport': 'memory'},
'transport': 'memory',
'heartbeat': FLAGS.rabbit_heartbeat},
{'hostname': '::1',
'userid': FLAGS.rabbit_userid,
'password': FLAGS.rabbit_password,
'port': 2345,
'virtual_host': FLAGS.rabbit_virtual_host,
'transport': 'memory'},
'transport': 'memory',
'heartbeat': FLAGS.rabbit_heartbeat},
{'hostname': '2001:0db8:85a3:0042:0000:8a2e:0370:7334',
'userid': FLAGS.rabbit_userid,
'password': FLAGS.rabbit_password,
'port': 5672,
'virtual_host': FLAGS.rabbit_virtual_host,
'transport': 'memory'},
'transport': 'memory',
'heartbeat': FLAGS.rabbit_heartbeat},
]
}

Expand Down

0 comments on commit c37f6aa

Please sign in to comment.