Menu Search

client.py

import sys, optparse
from proton import *

parser = optparse.OptionParser(usage="usage: %prog <addr> <subject>",
                               description="simple message server")

parser.add_option("-r", "--reply_to", default="~/replies",
                  help="address: [amqp://]<domain>[/<name>] (default %default)")

opts, args = parser.parse_args()

if len(args) != 2:
  parser.error("incorrect number of arguments")

address, subject = args

mng = Messenger()
mng.start()

msg = Message()
msg.address = address
msg.subject = subject
msg.reply_to = opts.reply_to

mng.put(msg)
mng.send()

if opts.reply_to[:2] == "~/":
  mng.recv(1)
  try:
    mng.get(msg)
    print msg.address, msg.subject
  except Exception, e:
    print e

mng.stop()

Download this file