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)
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)
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"))
def reply(body): msg = Message("GPS", "zeno_master_queue", "Operation", body) producer.reply(msg)