I like what I see, I have a bunch of questions.

from qpid.api import *

# open a connection
conn = Connection.open("localhost")
conn.start()


If I start the connection before creating sessions, does that mean each connection starts as soon as it is created?

# create a session
ssn = conn.session()

# send a message
sender = ssn.sender("my-queue")
sender.send("Hello World!")
# fetch the message
receiver = ssn.receiver("my-queue")
msg = receiver.fetch(0)

print msg

# acknowledge the message
ssn.acknowledge(msg)

How does this work with Topic Exchanges? The XML Exchange?

Could there be a default timeout for receiverfetch()?


# define a listener
def printer(msg):
  print "L: %r" % msg
  ssn.acknowledge(msg)

# register the listener
receiver.listen(printer)

# send a bunch more messages
for content in ["this", "is", "a", "test"]:
  sender.send(content)

# disconnect for a while
conn.stop()
conn.disconnect()

# reconnect and continue doing work
conn.connect()
conn.start()

# unregister the listener
receiver.listen(None)

Can a receiver have only one listener?

# send more messages
sender.send("Hello Again!")

# drain the queue
while True:
  try:
    msg = receiver.fetch(0)
    print "D: %r" % msg
  except Empty:
    break

# acknowledge all outstanding messages
ssn.acknowledge()
print "done"

# close the connection
conn.close()

How do I set delivery properties? Message properties?

How do I create queues? Bindings?

Jonathan

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:dev-subscr...@qpid.apache.org

Reply via email to