[Python] How to read messages from Activemq queues using python and STOMP

Discussão em 'Python' iniciado por Stack, Maio 31, 2025.

  1. Stack

    Stack Membro Participativo

    I access queues(activemq) using the link http://10.41.248.10:8161/admin/queues.jsp. I wanted to read the message from the queue name:Notificationqueue. I wanted to use python and STOMP. The username and password to the queue is admin/admin. Please help me step by step to get the message from queue name:Notificationqueue. Below is my code, please help to complete the code

    #!/usr/bin/env python

    import time
    import sys
    import stomp

    class MyListener(object):
    def on_error(self, headers, message):
    print 'received an error %s' % message
    def on_message(self, headers, message):
    print 'received a message %s' % message

    conn = stomp.Connection(host_and_ports=[('10.41.248.10', 61616)])
    conn.set_listener('', MyListener())
    conn.start()
    conn.connect("admin","admin",wait=True)
    conn.subscribe(destination='queue://Notificationqueue', id = '1', ack='auto')
    time.sleep(2)
    conn.disconnect()


    When I run this, I get the error,

    No handlers could be found for logger "stomp.py"


    conn.connect("admin","admin", wait=True)
    File "C:\Python27\lib\site-packages\stomp\connect.py", line 164, in connect
    Protocol11.connect(self, *args, **kwargs)
    File "C:\Python27\lib\site-packages\stomp\protocol.py", line 340, in connect
    self.transport.wait_for_connection()
    File "C:\Python27\lib\site-packages\stomp\transport.py", line 327, in wait_for_connection
    raise exception.ConnectFailedException()
    ConnectFailedException


    . Please help in completing this code at the earliest. Do ask me if you need more information

    Continue reading...

Compartilhe esta Página