#!/usr/bin/env python from Broker.Clients import Async as Client from Broker.Transport import TCP, UDP import logging logging.basicConfig(level=logging.WARN) server = 'broker.bk.sapo.pt' destination = '/python/tests' destination_type = 'QUEUE' broker = Client(TCP(host=server)) def callback(msg): print "%r\t%r" % (msg.destination, msg.message.payload) broker.subscribe(destination, callback, destination_type) broker.start() broker.join()
#!/usr/bin/env python from Broker.Messages import Message, Poll, Acknowledge from Broker.Transport import TCP, UDP from Broker.Codecs import Codec #auto codec selection (thrift or protobuf if thrift isn't installed) from Broker.Clients import Minimal server = 'broker.bk.sapo.pt' destination = '/python/tests/expiration' N = 10000 broker = Minimal(codec=Codec(), transport=TCP(host=server)) for n in xrange(N): broker.send(Poll(destination=destination, timeout=0)) message = broker.receive() broker.send( Acknowledge(message_id=message.message.id, destination=message.subscription)) print message.message.payload