本文整理汇总了Java中org.apache.activemq.broker.jmx.QueueViewMBean.purge方法的典型用法代码示例。如果您正苦于以下问题:Java QueueViewMBean.purge方法的具体用法?Java QueueViewMBean.purge怎么用?Java QueueViewMBean.purge使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.activemq.broker.jmx.QueueViewMBean
的用法示例。
在下文中一共展示了QueueViewMBean.purge方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSendNonPersistentQueueMessagesAMQP
import org.apache.activemq.broker.jmx.QueueViewMBean; //导入方法依赖的package包/类
@Test
public void testSendNonPersistentQueueMessagesAMQP() throws Exception {
connection = createAmqpConnection();
Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
Destination destination = session.createQueue(getDestinationName());
MessageProducer producer = session.createProducer(destination);
QueueViewMBean queueView = getProxyToQueue(getDestinationName());
// Warm
produceMessages(session, producer);
long totalCycleTime = 0;
for (int i = 0; i < ITERATIONS; i++) {
totalCycleTime += produceMessages(session, producer);
queueView.purge();
}
long smoothedTime = totalCycleTime / ITERATIONS;
LOG.info("Total time for QPid client = {}", TimeUnit.NANOSECONDS.toMillis(smoothedTime));
}
示例2: testPurgeLargeQueueWithConsumer
import org.apache.activemq.broker.jmx.QueueViewMBean; //导入方法依赖的package包/类
public void testPurgeLargeQueueWithConsumer() throws Exception {
applyBrokerSpoolingPolicy();
createProducerAndSendMessages(NUM_TO_SEND);
QueueViewMBean proxy = getProxyToQueueViewMBean();
createConsumer();
long start = System.currentTimeMillis();
LOG.info("purging..");
proxy.purge();
LOG.info("purge done: " + (System.currentTimeMillis() - start) + "ms");
assertEquals("Queue size is not zero, it's " + proxy.getQueueSize(), 0, proxy.getQueueSize());
assertEquals("usage goes to duck", 0, proxy.getMemoryPercentUsage());
Message msg;
do {
msg = consumer.receive(1000);
if (msg != null) {
msg.acknowledge();
}
} while (msg != null);
assertEquals("Queue size not valid", 0, proxy.getQueueSize());
}
示例3: testSendNonPersistentQueueMessagesOpenWire
import org.apache.activemq.broker.jmx.QueueViewMBean; //导入方法依赖的package包/类
@Test
public void testSendNonPersistentQueueMessagesOpenWire() throws Exception {
connection = createActiveMQConnection();
Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
Destination destination = session.createQueue(getDestinationName());
MessageProducer producer = session.createProducer(destination);
producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
QueueViewMBean queueView = getProxyToQueue(getDestinationName());
// Warm
produceMessages(session, producer);
long totalCycleTime = 0;
for (int i = 0; i < ITERATIONS; i++) {
totalCycleTime += produceMessages(session, producer);
queueView.purge();
}
long smoothedTime = totalCycleTime / ITERATIONS;
LOG.info("Total time for ActiveMQ client = {}", TimeUnit.NANOSECONDS.toMillis(smoothedTime));
}
示例4: testPurgeLargeQueue
import org.apache.activemq.broker.jmx.QueueViewMBean; //导入方法依赖的package包/类
public void testPurgeLargeQueue() throws Exception {
applyBrokerSpoolingPolicy();
createProducerAndSendMessages(NUM_TO_SEND);
QueueViewMBean proxy = getProxyToQueueViewMBean();
LOG.info("purging..");
org.apache.log4j.Logger log4jLogger = org.apache.log4j.Logger.getLogger(org.apache.activemq.broker.region.Queue.class);
final AtomicBoolean gotPurgeLogMessage = new AtomicBoolean(false);
Appender appender = new DefaultTestAppender() {
@Override
public void doAppend(LoggingEvent event) {
if (event.getMessage() instanceof String) {
String message = (String) event.getMessage();
if (message.contains("purged of " + NUM_TO_SEND + " messages")) {
LOG.info("Received a log message: {} ", event.getMessage());
gotPurgeLogMessage.set(true);
}
}
}
};
Level level = log4jLogger.getLevel();
log4jLogger.setLevel(Level.INFO);
log4jLogger.addAppender(appender);
try {
proxy.purge();
} finally {
log4jLogger.setLevel(level);
log4jLogger.removeAppender(appender);
}
assertEquals("Queue size is not zero, it's " + proxy.getQueueSize(), 0, proxy.getQueueSize());
assertTrue("cache is disabled, temp store being used", !proxy.isCacheEnabled());
assertTrue("got expected info purge log message", gotPurgeLogMessage.get());
}
示例5: testConsumeRateFromQueue
import org.apache.activemq.broker.jmx.QueueViewMBean; //导入方法依赖的package包/类
@Test
public void testConsumeRateFromQueue() throws Exception {
connection = createAmqpConnection();
connection.start();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Queue queue = session.createQueue(getDestinationName());
// Warm Up the broker.
produceMessages(queue, MSG_COUNT);
consumerMessages(queue, MSG_COUNT);
QueueViewMBean queueView = getProxyToQueue(getDestinationName());
queueView.purge();
List<Long> sendTimes = new ArrayList<Long>();
long cumulative = 0;
for (int i = 0; i < NUM_RUNS; ++i) {
produceMessages(queue, MSG_COUNT);
long result = consumerMessages(queue, MSG_COUNT);
sendTimes.add(result);
cumulative += result;
LOG.info("Time to send {} topic messages: {} ms", MSG_COUNT, result);
queueView.purge();
}
long smoothed = cumulative / NUM_RUNS;
LOG.info("Smoothed send time for {} messages: {}", MSG_COUNT, smoothed);
}
示例6: testConsumeRateFromQueueAsync
import org.apache.activemq.broker.jmx.QueueViewMBean; //导入方法依赖的package包/类
@Test
public void testConsumeRateFromQueueAsync() throws Exception {
connection = createAmqpConnection();
connection.start();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Queue queue = session.createQueue(getDestinationName());
// Warm Up the broker.
produceMessages(queue, MSG_COUNT);
consumerMessagesAsync(queue, MSG_COUNT);
QueueViewMBean queueView = getProxyToQueue(getDestinationName());
List<Long> sendTimes = new ArrayList<Long>();
long cumulative = 0;
for (int i = 0; i < NUM_RUNS; ++i) {
produceMessages(queue, MSG_COUNT);
long result = consumerMessagesAsync(queue, MSG_COUNT);
sendTimes.add(result);
cumulative += result;
LOG.info("Time to send {} topic messages: {} ms", MSG_COUNT, result);
queueView.purge();
}
long smoothed = cumulative / NUM_RUNS;
LOG.info("Smoothed send time for {} messages: {}", MSG_COUNT, smoothed);
}
示例7: testProduceRateToQueue
import org.apache.activemq.broker.jmx.QueueViewMBean; //导入方法依赖的package包/类
@Test
public void testProduceRateToQueue() throws Exception {
connection = createActiveMQConnection();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Queue queue = session.createQueue(getDestinationName());
// Warm Up the broker.
produceMessages(queue, MSG_COUNT);
QueueViewMBean queueView = getProxyToQueue(getDestinationName());
queueView.purge();
List<Long> sendTimes = new ArrayList<Long>();
long cumulative = 0;
for (int i = 0; i < NUM_RUNS; ++i) {
long result = produceMessages(queue, MSG_COUNT);
sendTimes.add(result);
cumulative += result;
LOG.info("Time to send {} queue messages: {} ms", MSG_COUNT, result);
queueView.purge();
}
long smoothed = cumulative / NUM_RUNS;
LOG.info("Smoothed send time for {} messages: {}", MSG_COUNT, smoothed);
}
示例8: testProduceRateToQueue
import org.apache.activemq.broker.jmx.QueueViewMBean; //导入方法依赖的package包/类
@Test
public void testProduceRateToQueue() throws Exception {
connection = createAmqpConnection();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Queue queue = session.createQueue(getDestinationName());
// Warm Up the broker.
produceMessages(queue, MSG_COUNT);
QueueViewMBean queueView = getProxyToQueue(getDestinationName());
queueView.purge();
List<Long> sendTimes = new ArrayList<Long>();
long cumulative = 0;
for (int i = 0; i < NUM_RUNS; ++i) {
long result = produceMessages(queue, MSG_COUNT);
sendTimes.add(result);
cumulative += result;
LOG.info("Time to send {} queue messages: {} ms", MSG_COUNT, result);
queueView.purge();
}
long smoothed = cumulative / NUM_RUNS;
LOG.info("Smoothed send time for {} messages: {}", MSG_COUNT, smoothed);
TimeUnit.SECONDS.sleep(1);
}