Reputation: 11307
I have a JMS client written in python using Stomp. I'm running Apache activemq 5.10.0.
I have a queue called TEST, and the client I have prints log messages saying that it is reading messages from the queue, but the print statements in my onMessage method do not work. ActiveMQ shows that the client has read the message, and the logger in the Stomp lib prints a message, but the onMessage() print statements do not show up.
Any suggestions?
Here is the code:
import time
import sys
import logging
import stomp
from stomp import ConnectionListener
queuename = sys.argv[1]
logging.basicConfig( level=logging.DEBUG)
class MyListener(ConnectionListener):
message_count = 0
def on_error(self, headers, message):
print 'received an error %s' % message
# onMessage is WRONG - should be on_message
# def onMessage(self, headers, message):
def on_message(self, headers, message):
print headers
print str(message)
print type(message)
print "Message %d" %(message_count)
message_count = message_count + 1
print 'received a message ...%s...' % message
conn = stomp.Connection()
conn.set_listener('', MyListener())
conn.start()
conn.connect()
queue = '/queue/%s' % queuename
print "Queue is [%s]" % queue
print "subscribe: %s" % conn.subscribe
conn.subscribe(destination=queue, id=123421, ack='auto')
while 1:
time.sleep(2)
Upvotes: 2
Views: 3717
Reputation: 11307
Found it, of course about 30 minutes after posting.. The method onMessage should be on_message.
This was example code that I modified and was not correct.
Make that change and it works fine.
Upvotes: 3