I have a stomp listener on an Activemq queue which just drops itself after being up for a while. The program itself shows no error and shows in running state but listener listed on Activemq UI just shows 0 after some time. I am using this code
class MyListener(stomp.ConnectionListener):
def __init__(self, conn):
self.conn = conn
self.msg = []
def on_error(self, frame):
print('received an error "%s"' % frame.body)
def on_message(self, frame):
print('received a message "%s" from queue' % frame.body)
headers = frame.headers
self.conn.ack(id=headers["message-id"], subscription=headers["subscription"])
def on_disconnected(self):
print('disconnected')
connect_and_subscribe(self.conn)
def main():
conn = stomp.Connection([('localhost', 61613)])
a = MyListener(conn)
conn.set_listener('', a)
connect_and_subscribe(conn)
try:
while True:
if not conn.is_connected():
print('disconnected... connecting again')
connect_and_subscribe(conn)
time.sleep(5)
except KeyboardInterrupt:
print('interrupted - so exiting!')
conn.disconnect()