Code example for ArrayBlockingQueue

Methods: add, sleep

0
        Hello mbean = new Hello();
        mBeanServer.registerMBean(mbean, name);
 
        // MXBean 
        name = new ObjectName("com.xiaomi.stonelion.jmx:type=QueueSampler");
        Queue<String> queue = new ArrayBlockingQueue<String>(10);
        queue.add("request-1");
        queue.add("request-2");
        queue.add("request-3");
        QueueSampler mxbean = new QueueSampler(queue);
        mBeanServer.registerMBean(mxbean, name);
 
        System.out.println("Wait forever...");
        Thread.sleep(Integer.MAX_VALUE);
    } 
}