Пример #1
0
def setup():
    global conn
    conn = msgbus.Connection(bus_ip, bus_port, vhost, username, password,
                             funcode_dict.funcode_dict)
    conn.bind_queue('entry', 'testmoney_rsp', routing_key='money_rsp')
    clear_queue(conn)
    print 'setup() complete'
Пример #2
0
def publish_main(bus_ip, bus_port, vhost, username, password):
    conn = msgbus.Connection(bus_ip, bus_port, vhost, username, password, funcode_dict.funcode_dict)
    t0 = time.time()
    for account_id in range(20000, 21000):
        logout_req = UserTas1_pb2.LogoutReq(Header = common_pb2.MessageHead(AccountId=account_id))
        conn.publish('entry', 'user_rsp', 0, logout_req)
        time.sleep(0.01) # 发送速度太快,造成消息队列拥塞和丢包?
    dt = time.time() - t0
    print 'all sent in %f, speed=%f'%(dt, 1000/dt)
Пример #3
0
def setup():
    global conn
    conn = msgbus.Connection(bus_ip, bus_port, vhost, username, password, funcode_dict.funcode_dict)
    conn.bind_queue('entry', 'testuser_rsp', routing_key='user_rsp')
    for account_id in range(20000, 20100):
        logout_req = UserTas1_pb2.LogoutReq(Header = common_pb2.MessageHead(AccountId=account_id))
        conn.publish('entry', 'user_rsp', 0, logout_req)
        time.sleep(0.01) # 发送速度太快,造成消息队列拥塞和丢包?
    clear_queue()
    print 'setup() complete'
Пример #4
0
def setup():
    global conn, order_rsp_chan, money_req_chan, sess_id, server_id
    global order_generator, request_id_generator
    conn = msgbus.Connection(bus_ip, bus_port, vhost, username, password, funcode.funcode_dict)
    conn.bind_queue('entry', 'testorder_rsp', routing_key='order_rsp')
    sess_id = 101
    server_id = 100100
    order_id = (int(time.time())<<32) + (server_id<<16)
    order_generator = OrderIDGenerator(1) #server_id=1
    request_id_generator = RequestIDGenerator()