我正在处理一个stomp使用者对终止事件的处理(on_heartbeat_timeout和on_disconnected)。我的on_heartbeat_timeout看起来像:
def on_heartbeat_timeout(self):
logger.debug("Heartbeat timed out - attempting a reconnect")
for n in range(1, 31):
try:
logger.debug("Reconnecting: Attempt %d" % n)
self.conn.set_listener('', self)
self.conn.start()
self.conn.connect('admin', 'password', wait=True)
conn.subscribe('/queue/BVEvent', id=uuid.uuid4())
logger.debug("Connected")
break
except exception.ConnectFailedException:
_, e, _ = sys.exc_info()
# Oh, still can't reconnect
logger.error("Reconnect attempt failed: %s" % e)
time.sleep(2)
我正在强制SIGKILL对消息代理的条件,并且on_heartbeat_timeout正在触发。我正在重新启动代理,但在我重新启动之前,我从stomp.py日志记录(如预期的那样)获得主机拒绝连接的指示。但是,当我重新启动经纪人时..
2016-05-16 11:07:42,969:__main__:ERROR :StompReceiverThread-3:77:Reconnect attempt failed:
2016-05-16 11:07:44,969:__main__:DEBUG :StompReceiverThread-3:67:Reconnecting: Attempt 4
2016-05-16 11:07:44,969:stomp.py:INFO :StompReceiverThread-3:655:Attempting connection to host bvesb, port 61690
2016-05-16 11:07:44,972:stomp.py:INFO :StompReceiverThread-3:689:Established connection to host bvesb, port 61690
2016-05-16 11:07:44,972:stomp.py:INFO :Thread-4 :300:Starting receiver loop
2016-05-16 11:07:44,973:stomp.py:DEBUG :StompReceiverThread- 3:245:Sending frame ['STOMP', '\n', 'accept-version:1.1\n', 'heart-beat:10000,1000\n', 'login:admin\n', 'passcode:password\n', '\n', '\x00']
2016-05-16 11:07:45,181:stomp.py:DEBUG :StompReceiverThread-4:169:Received frame: 'CONNECTED', headers={'session': 'bvbroker-21b3', 'heart-beat': '100,10000', 'host-id': 'bvbroker', 'version': '1.1', 'user-id': 'admin', 'server': 'apache-apollo/1.7.1'}, body=''
2016-05-16 11:07:45,182:__main__:DEBUG :StompReceiverThread-4:43:Connected
2016-05-16 11:07:45,182:stomp.py:DEBUG :StompReceiverThread-3:245:Sending frame ['SUBSCRIBE', '\n', 'ack:auto\n', 'destination:/queue/BVEvent\n', 'id:59094787-8f9b-4a0c-92ba-d5612a701e00\n', '\n', '\x00']
2016-05-16 11:07:45,182:__main__:DEBUG :StompReceiverThread-3:72:Connected
2016-05-16 11:07:45,183:stomp.py:INFO :StompReceiverThread-3:327:Receiver loop ended
2016-05-16 11:07:46,041:stomp.py:DEBUG :StompReceiverThread-4:169:Received frame: 'heartbeat', headers={}, body=None
2016-05-16 11:07:46,042:stomp.py:INFO :StompReceiverThread-4:327:Receiver loop ended
据我所知,接收器循环正在终止,当然我不再接收来自经纪人的消息。
关于我在这里做错了什么建议?