无法使用STOMP向activemq发送消息

时间:2019-05-12 07:24:42

标签: python activemq stomp

我正在尝试使用STOMP协议将消息发送到activemq,但是出现以下错误:

(limetray) Vaibhavs-MacBook-Air:Desktop vaibhav$ python receiver_topic.py heyhey
Unknown response frame type: ';activemq' (frame length was 11)
Unknown response frame type: '
                              ' (frame length was 2)
Unknown response frame type: ')' (frame length was 2)
Unknown response frame type: '
                              ' (frame length was 1)
Unknown response frame type: 'tcpnodelayenabled' (frame length was 20)
Unknown response frame type: 'sizeprefixdisabled' (frame length was 20)
Unknown response frame type: '  cachesize' (frame length was 11)
Unknown response frame type: '' (frame length was 1)
Unknown response frame type: '

我正在使用以下python脚本发送消息:

class MyListener(stomp.ConnectionListener):
    def on_error(self, headers, message):
        print('received an error "%s"' % message)
    def on_message(self, headers, message):
        print('received a message "%s"' % message)
hosts = [('localhost', 61616)]

conn = stomp.Connection(host_and_ports=hosts)
conn.set_listener('', MyListener())
conn.start()
conn.connect('admin', 'admin', wait=True,headers = {'client-id': 'clientname'} )
conn.subscribe(destination='A.B.C.D', id=1, ack='auto',headers = {'subscription-type': 'MULTICAST','durable-subscription-name':'someValue'})
#conn.subscribe({destination=config['/topic/test'], ack:'auto', 'activemq.subscriptionName':'SampleSubscription'})
#conn.subscribe(destination='/topic/testTopic', ack='auto', headers = {'activemq.subscriptionName': 'myhostname'})

conn.send(body=' '.join(sys.argv[1:]), destination='A.B.C.D')

time.sleep(2)
conn.disconnect()

用于调用脚本的命令:

python receiver_topic.py heyhey

我认为需要将一些内容添加到activemq.xml文件中。关于此的任何建议将非常有帮助。

1 个答案:

答案 0 :(得分:1)

从提供的内容来看,似乎您正在连接到代理上的Openwire端口,该端口默认为“ 61616”,而STOMP端口通常为“ 61613”,所以我的建议是检查STOMP连接器绑定到哪个端口并确保您正在连接到那个。