def runTest(self): p = MessageProducer("meta-test") print p._conn_dict print p._broker_dict print p._partition_list assert len(p._conn_dict) == 1 assert len(p._broker_dict) == 1 assert len(p._partition_list) == 1 assert p._partition_list[0].broker_id == 0 assert p._partition_list[0].partition == 0 send_rt = p.send(Message("meta-test", "hello")) assert send_rt.success assert not send_rt.error # close connection by hand p._conn_dict[0].close() send_rt = p.send(Message("meta-test", "hello")) assert send_rt.success assert not send_rt.error zk = p.zk topic_path = "%s/%s" % (p._broker_topic_path, "meta-test") print p._safe_zk_get_children(topic_path, None) zk.delete("%s/0-m" % topic_path) time.sleep(1) assert len(p._conn_dict) == 0 assert len(p._broker_dict) == 0 assert len(p._partition_list) == 0 zk.create("%s/0-m" % topic_path, "1") time.sleep(1) assert len(p._conn_dict) == 1 assert len(p._broker_dict) == 1 assert len(p._partition_list) == 1 assert p._partition_list[0].broker_id == 0 assert p._partition_list[0].partition == 0 send_rt = p.send(Message("meta-test", "hello")) assert send_rt.success assert not send_rt.error p.close()
def runTest(self): p = MessageProducer("meta-test") print(p._conn_dict) print(p._broker_dict) print(p._partition_list) assert len(p._conn_dict) == 1 assert len(p._broker_dict) == 1 assert len(p._partition_list) == 1 assert p._partition_list[0].broker_id == 0 assert p._partition_list[0].partition == 0 send_rt = p.send(Message("meta-test", "hello")) assert send_rt.success assert not send_rt.error #close connection by hand p._conn_dict[0].close() send_rt = p.send(Message("meta-test", "hello")) assert send_rt.success assert not send_rt.error zk = p.zk topic_path = "%s/%s" % (p._broker_topic_path, "meta-test") print(p._safe_zk_get_children(topic_path, None)) zk.delete("%s/0-m" % topic_path) time.sleep(1) assert len(p._conn_dict) == 0 assert len(p._broker_dict) == 0 assert len(p._partition_list) == 0 zk.create("%s/0-m" % topic_path, "1") time.sleep(1) assert len(p._conn_dict) == 1 assert len(p._broker_dict) == 1 assert len(p._partition_list) == 1 assert p._partition_list[0].broker_id == 0 assert p._partition_list[0].partition == 0 send_rt = p.send(Message("meta-test", "hello")) assert send_rt.success assert not send_rt.error p.close()
from metaq.producer import Message,MessageProducer from time import time p=MessageProducer("avos-fetch-tasks") message=Message("avos-fetch-tasks","http://www.taobao.com") start=time() for i in range(0,10000): sent=p.send(message) if not sent.success: print "send failed" finish=time() secs=finish-start print "duration:%s seconds" % (secs) print "tps:%s msgs/second" % (10000/secs) p.close()
from metaq.producer import Message, MessageProducer producer = MessageProducer("meta-test") message = Message("meta-test", "http://www.taobao.com") print(producer.send(message)) producer.close()
from metaq.producer import Message,MessageProducer producer = MessageProducer("meta-test") message = Message("meta-test", "http://www.taobao.com") print producer.send(message) producer.close()
#duration:1.90639591217 seconds #tps:5245.50012731 msgs/second from metaq.producer import Message, MessageProducer from time import time p = MessageProducer("avos-fetch-tasks", zk_root="/avos-fetch-meta") message = Message("avos-fetch-tasks", "http://www.taobao.com") start = time() for i in range(0, 10000): sent = p.send(message) if not sent.success: print "send failed" finish = time() secs = finish - start print "duration:%s seconds" % (secs) print "tps:%s msgs/second" % (10000 / secs) p.close()