Ejemplo n.º 1
0
def on_event(ch, method, properties, body):
    try:
        queue_msg = Message().from_queue(body)
        print "[x] request: ", queue_msg.to_queue()

        response_msg = OperationManager(queue_msg).select()
        producer.reply(response_msg)

        # 100 ms of wait to end communication
        time.sleep(5 / 10)  # pode ir para o fim para nao dar timeout no gajo que fez o pedido.

        print "[x] response: ", response_msg.to_queue()
        print

    except Exception as ex:
        print "[x] error: ", ex

    finally:
        ch.basic_ack(delivery_tag=method.delivery_tag)
Ejemplo n.º 2
0
def on_event(ch, method, properties, body):
    try:
        queue_msg = Message().from_queue(body)
        print "[x] request: ", queue_msg.to_queue()

        response_msg = OperationManager(queue_msg).select()
        producer.reply(response_msg)

        # 100 ms of wait to end communication
        time.sleep(
            5 / 10
        )  # pode ir para o fim para nao dar timeout no gajo que fez o pedido.

        print "[x] response: ", response_msg.to_queue()
        print

    except Exception as ex:
        print "[x] error: ", ex

    finally:
        ch.basic_ack(delivery_tag=method.delivery_tag)
Ejemplo n.º 3
0
def on_response(ch, method, props, body):
    print("on response: " + body)
    ch.basic_ack(method.delivery_tag)
    producer.reply(
        Message("GPS", "zeno_master_queue", "coordinates", "original message:" + body + " and this is the reply"))
Ejemplo n.º 4
0
 def reply(body):
     msg = Message("GPS", "zeno_master_queue", "Operation", body)
     producer.reply(msg)