With a little more experimentation, creating a new exchange is not
neccessary, they key part is to create a new queue for each reciever,
heres the same effect using a routing key and just one exchange.

Sending.

 conn.send(str(i), exchange="myexchange", destination='users.'+ user)


Recieving


import stomp
from amqplib import client_0_8 as amqp
import sys


conn = amqp.Connection(host="localhost:5672", userid="guest",
password="guest",
 virtual_host="/", insist=False)


user = sys.argv[1]
chan = conn.channel()

chan.exchange_declare("myexchange", 'topic', durable=True)
qname,_,_ = chan.queue_declare(auto_delete=True, durable=True)
chan.queue_bind(qname, exchange="myexchange", routing_key="users." + user)
chan.close()
conn.close()

class MyListener(object):
    def on_error(self, headers, message):
        print 'recieved an error %s' % message

    def on_message(self, headers, message):
        print 'recieved a message %s' % message

conn = stomp.Connection([('0.0.0.0', 61613), ('127.0.0.1', 61613)],
'browser', 'browser')
conn.set_listener('', MyListener())
conn.start()
conn.connect(username="guest", password="guest")
headers = {}

conn.subscribe(destination=qname, ack='auto')

while True:
    pass
conn.disconnect()







--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Python Ireland" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.ie/group/pythonireland?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to