[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 intenalCountDeliveryMessages(final String filterStr, final String groupByPropertyStr) throws Exception { + checkStarted(); + + clearIO(); + + Map 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> 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. ---
[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_r228619277 --- 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 intenalCountDeliveryMessages(final String filterStr, final String groupByPropertyStr) throws Exception { + checkStarted(); + + clearIO(); + + Map 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> deliveringMessages = queue.getDeliveringMessages(); --- End diff -- getDeliveringMessages() doesn't return a thead safe reference, as such the list can change beneath. this will expose thread safety issues ---
[GitHub] activemq-artemis pull request #2398: [ARTEMIS-2150] Counts the number of del...
GitHub user ArthurFritz opened a pull request: https://github.com/apache/activemq-artemis/pull/2398 [ARTEMIS-2150] Counts the number of delivering messages in this queue Create function this counts the number of delivering messages in this queue matching the specified filter. Create a other function this counts the number of delivering messages in this queue matching the specified filter, grouped by the given property field. [JIRA](https://issues.apache.org/jira/browse/ARTEMIS-2150) You can merge this pull request into a Git repository by running: $ git pull https://github.com/ArthurFritz/activemq-artemis feature/ARTEMIS-2150 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/activemq-artemis/pull/2398.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #2398 commit 1396ec6d825708994fa8d680f5c42480aacd410a Author: Arthur Fritz Santiago Date: 2018-10-26T17:39:09Z [ARTEMIS-2150] Counts the number of delivering messages in this queue ---