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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to