博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
【迁移2015-09-23 19:46】HTTPSQS(二)
阅读量:6691 次
发布时间:2019-06-25

本文共 2982 字,大约阅读时间需要 9 分钟。

  hot3.png

Test


  1. 新建工程,添加jar包httpsq4j.jar

  2. 新建JUnit测试

import com.daguu.lib.httpsqs4j.Httpsqs4j;import com.daguu.lib.httpsqs4j.HttpsqsClient;import com.daguu.lib.httpsqs4j.HttpsqsException;import com.daguu.lib.httpsqs4j.HttpsqsStatus;import org.junit.Before;import org.junit.Test;import org.springframework.util.StopWatch;import static junit.framework.Assert.fail;/** * Created by congye on 9/23/2015. */public class HttpsqsTest {    private final static String QUEUE_NAME = "KQ";    private static final int COUNT = 5000;    HttpsqsClient client;    /**     * @throws Exception     */    @Before    public void before() throws Exception {        Httpsqs4j.setConnectionInfo("192.168.56.101", 1218, "UTF-8");        client = Httpsqs4j.createNewClient();        HttpsqsStatus status = client.getStatus(QUEUE_NAME);        System.out.println(status.version);        System.out.println(status.queueName);        System.out.println(status.maxNumber);        System.out.println(status.getLap);        System.out.println(status.getPosition);        System.out.println(status.putLap);        System.out.println(status.putPosition);        System.out.println(status.unreadNumber);    }    /**     *发包测试     */    @Test    public void send() {        StopWatch stopWatch = new StopWatch("send");        stopWatch.start("set");        for (int i = 0; i < COUNT; i++) {            try {                client.putString(QUEUE_NAME, "http://" + i + "_twentwo_twentwo_twentwo_twentwo_twentwo_twentwo_twentwo_twentwo_twentwo_twentwo_twentwo_twentwo_twentwo_twentwo_twentwo_twentwo_twentwo_twentwo_twentwo_twentwo_twentwo_twentwo_twentwo_twentwo_twentwo_twentwo_twentwo_twentwo_twentwo_twentwo_twentwo");            } catch (Exception e) {                fail(e.getMessage());                e.printStackTrace();            }        }        stopWatch.stop();        System.out.println(stopWatch.prettyPrint());    }    /**     * 收包测试     */    @Test    public void receive() {        String value = "";        StopWatch stopWatch = new StopWatch("receive");        stopWatch.start("get");        try {            while (true) {                value = client.getString(QUEUE_NAME);                //System.out.println(value);            }        } catch (HttpsqsException e) {            System.out.println(e.getMessage());            //e.printStackTrace();        } finally {            stopWatch.stop();            System.out.println(stopWatch.prettyPrint());        }    }}
  1. 测试环境(和之前Kestrel环境相同)
- kestrel server服务环境,本地虚拟机,centOS6.6,只分配了650M内存,1核CPU- jdk7,单线程,单client- 消息个数5000,消息长度约256
  1. 发送测试结果
StopWatch 'send': running time (millis) = 3730-----------------------------------------ms     %     Task name-----------------------------------------03730  100%  set
  1. 接收测试结果
There's no data in queue [KQ].StopWatch 'receive': running time (millis) = 3644-----------------------------------------ms     %     Task name-----------------------------------------03644  100%  get

转载于:https://my.oschina.net/twen/blog/1925443

你可能感兴趣的文章
【NetApp】console和SP的相互切换
查看>>
301错误_302错误_404错误_500错误等
查看>>
PHP内核介绍及扩展开发指南—Extensions 的编写
查看>>
使用xshell打开centos中文显示为乱码
查看>>
达内实习——数据库编程、文件读写数据
查看>>
zabbix 监控percona
查看>>
我的友情链接
查看>>
HA高可用集群基础概念和原理
查看>>
MySQL over函数的用法
查看>>
Linux命令(9):mkdir命令
查看>>
vmstat命令
查看>>
poj2245 Lotto
查看>>
我的友情链接
查看>>
Oracle版本升级
查看>>
sizeof 的使用(标记一下)
查看>>
第 四 十 天:关 于 正 则 的 一 些 小 用 法
查看>>
编程 -- awk
查看>>
2012 #3 Arcane Numbers
查看>>
python 列表模拟堆栰
查看>>
Linux-Centos5.3中文乱码问题解决
查看>>