activemq如何配置在python中使用stomp

bit*_*cle 7 python activemq-classic stomp

我安装了activemq并在本地运行,但是当我运行以下脚本时,我收到一个错误:


#!/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=[('localhost', 61616)])
conn.set_listener('', MyListener())
conn.start()
conn.connect()
conn.subscribe(destination='/home/bitcycle/svn/cass/queue.test', ack='auto')
conn.send('Test', destination='/home/bitcycle/svn/cass/queue.test')
time.sleep(2)
conn.disconnect()
Run Code Online (Sandbox Code Playgroud)

错误:

./proc.py


No handlers could be found for logger "stomp.py"
Traceback (most recent call last):
  File "./proc.py", line 20, in 
    conn.disconnect()
  File "/usr/local/lib/python2.7/dist-packages/stomp.py-3.0.3-py2.7.egg/stomp/connect.py", line 387, in disconnect
    self.__send_frame_helper('DISCONNECT', '', utils.merge_headers([self.__connect_headers, headers, keyword_headers]), [ ])
  File "/usr/local/lib/python2.7/dist-packages/stomp.py-3.0.3-py2.7.egg/stomp/connect.py", line 453, in __send_frame_helper
    self.__send_frame(command, headers, payload)
  File "/usr/local/lib/python2.7/dist-packages/stomp.py-3.0.3-py2.7.egg/stomp/connect.py", line 489, in __send_frame
    raise exception.NotConnectedException()
stomp.exception.NotConnectedException
Run Code Online (Sandbox Code Playgroud)

有人可以帮我理解我需要做些什么才能让它发挥作用?我想使用activemq进行进程间通信.

Tim*_*ish 5

乍一看,我会说你正试图连接到错误的端口.开箱即用ActiveMQ配置为在端口61616上使用OpenWire协议,并且未启用Stomp.您需要检查ActiveMQ配置文件并确保已启用Stomp传输,我们使用的标准端口为Stomp的61613.有关配置Stomp:ActiveMQ Stomp Guide的一些信息,请参阅此页面