Skip to content

Instantly share code, notes, and snippets.

@carlosabalde
Created September 12, 2013 08:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carlosabalde/956af228116cd638ff0a to your computer and use it in GitHub Desktop.
Save carlosabalde/956af228116cd638ff0a to your computer and use it in GitHub Desktop.
Simple STOMP consumer for debugging purposes. Depends on stomp.py Python package (https://github.com/kwoli/stomp.py).
import time
import logging
import stomp
class SimpleListener(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
def consume(host, port, destination):
logging.basicConfig(level=logging.DEBUG)
connection = stomp.Connection(host_and_ports=[(host, port)])
try:
connection.set_listener('', SimpleListener())
connection.start()
connection.connect()
connection.subscribe(destination=destination, ack='auto')
while True:
time.sleep(1)
finally:
connection.disconnect()
if __name__ == '__main__':
consume('127.0.0.1', 61613, '/topic/whatever')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment