性能测试 - Locust Stomp client
Max.Bai
2018-02
1. 需要安装stomp
stomp 可以连接activemq,还有其他。
pip install stomp.py
2. 实现
详细过程不写了,直接上代码,代码是向activemq queue 发送消息.
需要看详解的到这里
import time
import random
import stomp
from locust import Locust, TaskSet, events, task
class StompClient(object):
def __init__(self, host, port):
self.conn = stomp.Connection10([(host, port)])
def __del__(self):
if self.conn:
print "disconnect..."
self.conn.disconnect()
def start(self):
start_time = time.time()
try:
self.conn.start()
except Exception as e:
total_time = int((time.time() - start_time)