git.net

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GitHub] activemq-artemis pull request #2398: [ARTEMIS-2150] Counts the number of del...


Github user michaelandrepearce commented on a diff in the pull request:

    https://github.com/apache/activemq-artemis/pull/2398#discussion_r228623226
  
    --- Diff: artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/QueueControlImpl.java ---
    @@ -740,6 +733,56 @@ public String countMessages(final String filterStr, final String groupByProperty
           }
        }
     
    +   @Override
    +   public long countDeliveringMessages(final String filterStr) throws Exception {
    +      Long value = intenalCountDeliveryMessages(filterStr, null).get(null);
    +      return value == null ? 0 : value;
    +   }
    +
    +   @Override
    +   public String countDeliveringMessages(final String filterStr, final String groupByProperty) throws Exception {
    +      return JsonUtil.toJsonObject(intenalCountDeliveryMessages(filterStr, groupByProperty)).toString();
    +   }
    +
    +   private Map<String, Long> intenalCountDeliveryMessages(final String filterStr, final String groupByPropertyStr) throws Exception {
    +      checkStarted();
    +
    +      clearIO();
    +
    +      Map<String, Long> result = new HashMap<>();
    +      try {
    +         Filter filter = FilterImpl.createFilter(filterStr);
    +         SimpleString groupByProperty = SimpleString.toSimpleString(groupByPropertyStr);
    +         if (filter == null && groupByProperty == null) {
    +            result.put(null, Long.valueOf(getDeliveringCount()));
    +         } else {
    +            Map<String, List<MessageReference>> deliveringMessages = queue.getDeliveringMessages();
    --- End diff --
    
    actually on further looking i see benefit in what you're doing, it keeps management logic and features out the core queue and consumer code, so actually +1 your approach.


---