I have activemq installed and running locally, but when I run the following script, I get an error:
#!/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()
error:
./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
Can someone help me to understand what i need to do to get this to work? I would like to use activemq for inter-process communication.
At first glance I'd say you are trying to connect to the wrong port. Out of the box ActiveMQ is configured to use OpenWire protocol on port 61616, and Stomp is not enabled. You need to check your ActiveMQ configuration file and ensure that the Stomp transport is enabled, the standard port we use is 61613 for Stomp. See this page for some info on configuring Stomp: ActiveMQ Stomp Guide