Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/284.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用python和STOMP从Activemq队列读取消息_Python_Activemq_Stomp - Fatal编程技术网

如何使用python和STOMP从Activemq队列读取消息

如何使用python和STOMP从Activemq队列读取消息,python,activemq,stomp,Python,Activemq,Stomp,我使用链接访问队列(activemq)。我想从队列名称中读取消息:Notificationqueue。我想使用python和STOMP。队列的用户名和密码为admin/admin。请帮助我逐步从队列名称:Notificationqueue获取消息。下面是我的代码,请帮我完成代码 #!/usr/bin/env python import time import sys import stomp class MyListener(object): def on_error(self, h

我使用链接访问队列(activemq)。我想从队列名称中读取消息:Notificationqueue。我想使用python和STOMP。队列的用户名和密码为admin/admin。请帮助我逐步从队列名称:Notificationqueue获取消息。下面是我的代码,请帮我完成代码

#!/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()
当我运行这个时,我得到了错误

 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

。请帮助尽早完成此代码。请询问我是否需要更多信息

连接到activemq时,您需要提供STOMP端口61613

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

端口61616不用于跺脚。我有一个类似的问题,但在更改端口号后,我没有得到连接失败异常

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