You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@activemq.apache.org by GitBox <gi...@apache.org> on 2022/10/18 12:59:35 UTC

[GitHub] [activemq-artemis] clebertsuconic commented on a diff in pull request #4260: ARTEMIS-4056 Paging Management optimizations

clebertsuconic commented on code in PR #4260:
URL: https://github.com/apache/activemq-artemis/pull/4260#discussion_r998179693


##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/QueueControlImpl.java:
##########
@@ -883,17 +883,12 @@ protected Map<String, Object>[] getFirstMessage() throws Exception {
       clearIO();
       try {
          List<Map<String, Object>> messages = new ArrayList<>();
-         queue.flushExecutor();
          final int attributeSizeLimit = addressSettingsRepository.getMatch(address).getManagementMessageAttributeSizeLimit();
-         try (LinkedListIterator<MessageReference> iterator = queue.browserIterator()) {
-            // returns just the first, as it's the first only
-            if (iterator.hasNext()) {
-               MessageReference ref = iterator.next();
-               Message message = ref.getMessage();
-               messages.add(message.toMap(attributeSizeLimit));
-            }
-            return messages.toArray(new Map[1]);
+         MessageReference firstMessage = queue.peekFirstMessage();
+         if (firstMessage != null) {
+            messages.add(firstMessage.getMessage().toMap(attributeSizeLimit));
          }
+         return messages.toArray(new Map[1]);

Review Comment:
   the idea is to avoid the iterator() for the first message. This might cause an outage if the system is under stress already.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org