Making Python script reading messages from ActiveMQ web console

I recently had a task to make Python script which can read/receive and show message from ActiveMQ web console.It has classes on_message and on_error. But, unfortunately it doesn't show anything.For example, I created topic named 'topictest' as you can see from image.

Here is my code:

import time
import sys
import stomp
class ConnectionListener(object): def on_error(self, message): print('received an error %s' % message)
def on_message(self, message): print('received a message %s' % message) print(message.body) with open('/usr/ubuntu/result.txt', 'w') as txt_file: txt_file.write(str(message))
conn = stomp.Connection(host_and_ports=[('localhost', 61613)])
conn.set_listener('', ConnectionListener())
conn.connect("admin", "admin", wait=True)
conn.subscribe(destination='/topic/topictest', id='1', ack='auto')
time.sleep(2)
conn.disconnect()
Reset to default

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like