ARTEMIS-2322: Expose Queue.getRate() data as JMX metric
This commit is contained in:
parent
5feb212efe
commit
dbb3a90fe6
|
@ -2242,6 +2242,13 @@ public interface AuditLogger extends BasicLogger {
|
|||
@Message(id = 601267, value = "User {0} is creating a core session on target resource {1} {2}", format = Message.Format.MESSAGE_FORMAT)
|
||||
void createCoreSession(String user, Object source, Object... args);
|
||||
|
||||
static void getProducedRate(Object source) {
|
||||
LOGGER.getMessageCount(getCaller(), source);
|
||||
}
|
||||
|
||||
@LogMessage(level = Logger.Level.INFO)
|
||||
@Message(id = 601268, value = "User {0} is getting produced message rate on target resource: {1} {2}", format = Message.Format.MESSAGE_FORMAT)
|
||||
void getProducedRate(String user, Object source, Object... args);
|
||||
|
||||
//hot path log using a different logger
|
||||
static void coreSendMessage(Object source, String user, Object... args) {
|
||||
|
|
|
@ -99,6 +99,12 @@ public interface QueueControl {
|
|||
@Attribute(desc = MESSAGE_COUNT_DESCRIPTION)
|
||||
long getMessageCount();
|
||||
|
||||
/**
|
||||
* Returns the rate of writing messages to the queue.
|
||||
*/
|
||||
@Attribute(desc = "rate of writing messages to the queue currently (based on default window function)")
|
||||
float getProducedRate();
|
||||
|
||||
/**
|
||||
* Returns the persistent size of all messages currently in this queue. The persistent size of a message
|
||||
* is the amount of space the message would take up on disk which is used to track how much data there
|
||||
|
|
|
@ -249,6 +249,17 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getProducedRate() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
AuditLogger.getProducedRate(queue);
|
||||
}
|
||||
checkStarted();
|
||||
|
||||
// This is an attribute, no need to blockOnIO
|
||||
return queue.getRate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getPersistentSize() {
|
||||
if (AuditLogger.isEnabled()) {
|
||||
|
@ -842,7 +853,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
AuditLogger.countMessages(queue, filterStr);
|
||||
}
|
||||
|
||||
Long value = intenalCountMessages(filterStr, null).get(null);
|
||||
Long value = internalCountMessages(filterStr, null).get(null);
|
||||
return value == null ? 0 : value;
|
||||
}
|
||||
|
||||
|
@ -852,10 +863,10 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
AuditLogger.countMessages(queue, filterStr, groupByProperty);
|
||||
}
|
||||
|
||||
return JsonUtil.toJsonObject(intenalCountMessages(filterStr, groupByProperty)).toString();
|
||||
return JsonUtil.toJsonObject(internalCountMessages(filterStr, groupByProperty)).toString();
|
||||
}
|
||||
|
||||
private Map<String, Long> intenalCountMessages(final String filterStr, final String groupByPropertyStr) throws Exception {
|
||||
private Map<String, Long> internalCountMessages(final String filterStr, final String groupByPropertyStr) throws Exception {
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
@ -890,7 +901,7 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
AuditLogger.countDeliveringMessages(queue, filterStr);
|
||||
}
|
||||
|
||||
Long value = intenalCountDeliveryMessages(filterStr, null).get(null);
|
||||
Long value = internalCountDeliveryMessages(filterStr, null).get(null);
|
||||
return value == null ? 0 : value;
|
||||
}
|
||||
|
||||
|
@ -900,10 +911,10 @@ public class QueueControlImpl extends AbstractControl implements QueueControl {
|
|||
AuditLogger.countDeliveringMessages(queue, filterStr, groupByProperty);
|
||||
}
|
||||
|
||||
return JsonUtil.toJsonObject(intenalCountDeliveryMessages(filterStr, groupByProperty)).toString();
|
||||
return JsonUtil.toJsonObject(internalCountDeliveryMessages(filterStr, groupByProperty)).toString();
|
||||
}
|
||||
|
||||
private Map<String, Long> intenalCountDeliveryMessages(final String filterStr, final String groupByPropertyStr) throws Exception {
|
||||
private Map<String, Long> internalCountDeliveryMessages(final String filterStr, final String groupByPropertyStr) throws Exception {
|
||||
checkStarted();
|
||||
|
||||
clearIO();
|
||||
|
|
|
@ -206,6 +206,11 @@ public class QueueControlUsingCoreTest extends QueueControlTest {
|
|||
return (Long) proxy.retrieveAttributeValue("messageCount", Long.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getProducedRate() {
|
||||
return (Long) proxy.retrieveAttributeValue("producedRate", Long.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getMessagesAdded() {
|
||||
return (Integer) proxy.retrieveAttributeValue("messagesAdded", Integer.class);
|
||||
|
|
Loading…
Reference in New Issue