Skip to content

Commit

Permalink
ARTEMIS-2322: Expose Queue.getRate() data as JMX metric
Browse files Browse the repository at this point in the history
  • Loading branch information
dmvolod authored and clebertsuconic committed Jul 15, 2019
1 parent 5feb212 commit dbb3a90
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2242,6 +2242,13 @@ static void createCoreSession(Object source, Object... args) {
@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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,17 @@ public long getMessageCount() {
}
}

@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()) {
Expand Down Expand Up @@ -842,7 +853,7 @@ public long countMessages(final String filterStr) throws Exception {
AuditLogger.countMessages(queue, filterStr);
}

Long value = intenalCountMessages(filterStr, null).get(null);
Long value = internalCountMessages(filterStr, null).get(null);
return value == null ? 0 : value;
}

Expand All @@ -852,10 +863,10 @@ public String countMessages(final String filterStr, final String groupByProperty
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();
Expand Down Expand Up @@ -890,7 +901,7 @@ public long countDeliveringMessages(final String filterStr) throws Exception {
AuditLogger.countDeliveringMessages(queue, filterStr);
}

Long value = intenalCountDeliveryMessages(filterStr, null).get(null);
Long value = internalCountDeliveryMessages(filterStr, null).get(null);
return value == null ? 0 : value;
}

Expand All @@ -900,10 +911,10 @@ public String countDeliveringMessages(final String filterStr, final String group
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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,11 @@ public long getMessageCount() {
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);
Expand Down

0 comments on commit dbb3a90

Please sign in to comment.