Exemplo n.º 1
0
#!/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()
Exemplo n.º 2
0
#!/usr/bin/env python

from Broker.Clients import Async as Client
from Broker.Transport import TCP, UDP

import logging
logging.basicConfig(level=logging.DEBUG)

server='localhost'
destination = '/python/tests'
destination_type = 'QUEUE'
N=10000

broker = Client(TCP(host=server))

broker.start()

for n in xrange(N):
    payload='Message number %d' % n
    broker.publish(destination=destination, destination_type=destination_type, payload=payload)

#broker.join()
Exemplo n.º 3
0
#!/usr/bin/env python

from Broker.Clients import Async as Client
from Broker.Transport import TCP, UDP

import logging
logging.basicConfig(level=logging.DEBUG)

server = 'localhost'
destination = '/python/tests'
destination_type = 'QUEUE'
N = 10000

broker = Client(TCP(host=server))

broker.start()

for n in xrange(N):
    payload = 'Message number %d' % n
    broker.publish(destination=destination,
                   destination_type=destination_type,
                   payload=payload)

#broker.join()
Exemplo n.º 4
0
#!/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 = "localhost"
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()