import sys, json, pika, random
AMQP_HOST = sys.argv[1]
AMQP_PORT = int(sys.argv[2])
AMQP_USER = sys.argv[3]
AMQP_PASSWORD = sys.argv[4]
creds_broker = pika.PlainCredentials(AMQP_USER, AMQP_PASSWORD)
conn_params = pika.ConnectionParameters(
    AMQP_HOST, port=AMQP_PORT, virtual_host="/", credentials=creds_broker)
conn_broker = pika.BlockingConnection(conn_params)
channel = conn_broker.channel()
msg = json.dumps({
    "ordernum": random.randrange(0, 100, 1),
    "type": "test type"
})
msg_props = pika.BasicProperties(content_type="application/json")
channel.basic_publish(
    body=msg,
    mandatory=True,
    exchange="shovel_exchange",
    properties=msg_props,
    routing_key="shovel_key")
print "Sent order message."