Menu Search

queue_browser.py

from proton.reactor import Container, Copy
from proton.handlers import MessagingHandler


class Recv(MessagingHandler):
    def __init__(self):
        super(Recv, self).__init__()

    def on_start(self, event):
        conn = event.container.connect("localhost:5672")
        event.container.create_receiver(conn, "examples", options=Copy())

    def on_message(self, event):
        print(event.message)
        if event.receiver.queued == 0 and event.receiver.drained:
            event.connection.close()


try:
    Container(Recv()).run()
except KeyboardInterrupt:
    pass

Download this file