Menu Search

send.py

import sys, optparse
from proton import *

parser = optparse.OptionParser(usage="usage: %prog [options] <msg_1> ... <msg_n>",
                               description="simple message sender")
parser.add_option("-a", "--address", default="amqp://0.0.0.0",
                  help="address: //<domain>[/<name>] (default %default)")

opts, args = parser.parse_args()
if not args:
  args = ["Hello World!"]

mng = Messenger()
mng.start()

msg = Message()
for m in args:
  msg.address = opts.address
  msg.body = unicode(m)
  mng.put(msg)

mng.send()
print "sent:", ", ".join(args)

mng.stop()

Download this file