0
votes

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

1

1 Answers

0
votes

You need to give the STOMP port 61613 when connecting to activemq http://activemq.apache.org/stomp.html

transportConnector name="stomp" uri="stomp://localhost:61613"

conn = stomp.Connection(host_and_ports=[('10.41.248.10', 61613)])

The port 61616 is not for used STOMP. I had a similar issue but after changing the port number I did not get connection fail exception.