An example of enabling heartbeats with eventlet could be:
import weakref
from kombu import Connection
from eventlet import spawn_after
def monitor_heartbeats(connection, rate=2):
if not connection.heartbeat:
return
interval = connection.heartbeat / 2.0
cref = weakref.ref(connection)
def heartbeat_check():
conn = cref()
if conn is not None and conn.connected: conn.heartbeat_check(rate=rate) spawn_after(interval, heartbeat_check)
return spawn_after(interval, heartbeat_check)
connection = Connection('pyamq://', heartbeat=10)
or:
connection = Connection('pyamqp://?heartbeat=10')
Additionally, I think adding support for consumer cancel notifications would aid in the master promotion issues I outlined above. From Ask's email:
- Consumer cancel notifications
Requires no changes to your code,
all you need is to properly reconnect when one of the
errors in Connection.channel_errors occur, which is handled
automatically by Connection.ensure / Connection.autoretry (I don't believe
Nova uses that, but it probably should).
Of course, this all requires updating to a newer version of kombu and amqp as well, but based on our experiences with rabbit, I really think the benefits of adding this functionality will help tremendously from an enterprise operationally ready standpoint. Without it, the HA story in rabbit is pretty dismal :-/
So it looks like Ask Solem outlines how we need to do heartbeats in this post:
https:/ /lists. launchpad. net/openstack/ msg15111. html
Specifically:
An example of enabling heartbeats with eventlet could be:
import weakref
from kombu import Connection
from eventlet import spawn_after
def monitor_ heartbeats( connection, rate=2): heartbeat: heartbeat / 2.0 ref(connection)
if not connection.
return
interval = connection.
cref = weakref.
def heartbeat_check():
conn.heartbeat _check( rate=rate)
spawn_ after(interval, heartbeat_check)
conn = cref()
if conn is not None and conn.connected:
return spawn_after( interval, heartbeat_check)
connection = Connection( 'pyamq: //', heartbeat=10)
or:
connection = Connection( 'pyamqp: //?heartbeat= 10')
Additionally, I think adding support for consumer cancel notifications would aid in the master promotion issues I outlined above. From Ask's email:
- Consumer cancel notifications
Requires no changes to your code, channel_ errors occur, which is handled autoretry (I don't believe
all you need is to properly reconnect when one of the
errors in Connection.
automatically by Connection.ensure / Connection.
Nova uses that, but it probably should).
Of course, this all requires updating to a newer version of kombu and amqp as well, but based on our experiences with rabbit, I really think the benefits of adding this functionality will help tremendously from an enterprise operationally ready standpoint. Without it, the HA story in rabbit is pretty dismal :-/