高并发消息处理器
1. MQEngine
?4.M2Queue
?
import java.util.concurrent.ExecutorService;import java.util.concurrent.Executors;import java.util.concurrent.atomic.AtomicLong;import lightmq.MQEngine;import lightmq.MyMessageHandler;/** * MQEngine测试类 * @author kevin * */public class TestMQ {public static void main(String[] args) {final AtomicLong l = new AtomicLong(0);// final MQEngine<String, MyMessageHandler> mq = new MQEngine<String, MyMessageHandler>(10, 50, MyMessageHandler.class);// 模拟客户并发数final int PRODUCER_SIZE = 200000;// 模拟每个客户平均请求次数final int REQUEST_TIME = 10;ExecutorService es = Executors.newFixedThreadPool(10);for (int i = 0; i < PRODUCER_SIZE; i++) {es.execute(new Runnable() {@Overridepublic void run() {for (int i = 0; i < REQUEST_TIME; i++) {mq.push(String.valueOf(l.incrementAndGet()));}}});}try {Thread.sleep(1000);} catch (InterruptedException e) {// TODO Auto-generated catch blocke.printStackTrace();}System.out.println(mq.size());}}?