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.
ActiveMQ supports the Stomp protocol and the Stomp - JMS mapping. This makes it easy to write a client in pure Ruby, Perl, Python or PHP for working with ActiveMQ.
STOMP is a text-orientated wire protocol that allows STOMP clients to communicate with STOMP Brokers. Apache ActiveMQ Artemis supports STOMP 1.0, 1.1 and 1.2. STOMP clients are available for several languages and platforms making it a good choice for interoperability.
“stomp.py” is a Python client library for accessing messaging servers (such as ActiveMQ, Artemis or RabbitMQ) using the STOMP protocol (STOMP v1. 0, STOMP v1. 1 and STOMP v1. 2). It can also be run as a standalone, command-line client for testing.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With