mirror of https://github.com/apache/activemq.git
https://issues.apache.org/jira/browse/AMQ-5743 - confine logging to the jmx purge op
This commit is contained in:
parent
b8698953f3
commit
23ecbe80d0
|
@ -28,11 +28,15 @@ import org.apache.activemq.broker.region.QueueMessageReference;
|
|||
import org.apache.activemq.command.ActiveMQDestination;
|
||||
import org.apache.activemq.command.Message;
|
||||
import org.apache.activemq.util.BrokerSupport;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Provides a JMX Management view of a Queue.
|
||||
*/
|
||||
public class QueueView extends DestinationView implements QueueViewMBean {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(QueueView.class);
|
||||
|
||||
public QueueView(ManagedRegionBroker broker, Queue destination) {
|
||||
super(broker, destination);
|
||||
}
|
||||
|
@ -53,7 +57,11 @@ public class QueueView extends DestinationView implements QueueViewMBean {
|
|||
}
|
||||
|
||||
public void purge() throws Exception {
|
||||
final long originalMessageCount = destination.getDestinationStatistics().getMessages().getCount();
|
||||
|
||||
((Queue)destination).purge();
|
||||
|
||||
LOG.info("{} purge of {} messages", destination.getActiveMQDestination().getQualifiedName(), originalMessageCount);
|
||||
}
|
||||
|
||||
public boolean removeMessage(String messageId) throws Exception {
|
||||
|
|
|
@ -1233,8 +1233,6 @@ public class Queue extends BaseDestination implements Task, UsageListener, Index
|
|||
|
||||
if (this.destinationStatistics.getMessages().getCount() > 0) {
|
||||
LOG.warn("{} after purge of {} messages, message count stats report: {}", getActiveMQDestination().getQualifiedName(), originalMessageCount, this.destinationStatistics.getMessages().getCount());
|
||||
} else {
|
||||
LOG.info("{} purged of {} messages", getActiveMQDestination().getQualifiedName(), originalMessageCount);
|
||||
}
|
||||
gc();
|
||||
this.destinationStatistics.getMessages().setCount(0);
|
||||
|
|
|
@ -95,7 +95,7 @@ public class QueuePurgeTest extends CombinationTestSupport {
|
|||
QueueViewMBean proxy = getProxyToQueueViewMBean();
|
||||
LOG.info("purging..");
|
||||
|
||||
org.apache.log4j.Logger log4jLogger = org.apache.log4j.Logger.getLogger(org.apache.activemq.broker.region.Queue.class);
|
||||
org.apache.log4j.Logger log4jLogger = org.apache.log4j.Logger.getLogger(org.apache.activemq.broker.jmx.QueueView.class);
|
||||
final AtomicBoolean gotPurgeLogMessage = new AtomicBoolean(false);
|
||||
|
||||
Appender appender = new DefaultTestAppender() {
|
||||
|
@ -103,7 +103,7 @@ public class QueuePurgeTest extends CombinationTestSupport {
|
|||
public void doAppend(LoggingEvent event) {
|
||||
if (event.getMessage() instanceof String) {
|
||||
String message = (String) event.getMessage();
|
||||
if (message.contains("purged of " + NUM_TO_SEND +" messages")) {
|
||||
if (message.contains("purge of " + NUM_TO_SEND +" messages")) {
|
||||
LOG.info("Received a log message: {} ", event.getMessage());
|
||||
gotPurgeLogMessage.set(true);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue