Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
38 lines (24 sloc) 884 Bytes
#!/usr/bin/env python
import time
import stomp
import base64
class SimpleListener:
def __init__(self, conn):
self.conn = conn
def on_message(self, headers, message):
binaryData = base64.b64decode(message)
print("Received {l} characters".format(l=len(message)))
print(" converted into {l} bytes".format(l=len(binaryData)))
with open("output.gif", "wb") as f:
f.write(binaryData)
def on_error(self, headers, message):
print("Received an error {e}".format(e=message))
destination = "/queue/test"
conn = stomp.Connection(host_and_ports=[("localhost", 61613)])
conn.set_listener('', SimpleListener(conn))
conn.start()
conn.connect(login="admin", passcode="admin")
conn.subscribe(id='simple_listener', destination=destination, ack='auto')
print("Waiting for messages...")
while True:
time.sleep(10)
You can’t perform that action at this time.