1 我用的是pyhton stomp 协议往activemq 发数据的
2 reconnect_attempts_max=-1 无线重连的意思
3 当我断开网络,等个几秒然后重连成功之后。从activemq 的管理界面看多出来一个。
4 最终解决 添加这个 heartbeats=(4000, 4000) 4000是4000毫秒。发送端和接收端4秒没有心跳就断开了
可行的代码:
class producer():
def __init__(self,dest):
self.user = "admin"
self.password = "admin"
self.host = "ip"
self.port = 61613
self.dest=dest
self.conn = stomp.Connection12(host_and_ports=[(self.host, self.port)],heartbeats=(4000, 4000), reconnect_attempts_max=-1,auto_content_length=False)
self.conn.connect(login=self.user, passcode=self.password,timeout=20)
def get_conn(self):
#self.conn = stomp.Connection12(host_and_ports=[(self.host, self.port)], reconnect_attempts_max=-1)
self.conn.connect(login=self.user, passcode=self.password)
return self.conn