diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalFilesRepository.java b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalFilesRepository.java index 6cdf92cad9..c094a439eb 100644 --- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalFilesRepository.java +++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalFilesRepository.java @@ -96,13 +96,11 @@ public class JournalFilesRepository { @Override public void run() { // if there's already an opened file there is no need to push a new one - if (openedFiles.isEmpty()) { - try { - pushOpenedFile(); - } catch (Exception e) { - ActiveMQJournalLogger.LOGGER.errorPushingFile(e); - fileFactory.onIOError(e, "unable to open ", null); - } + try { + pushOpenedFile(); + } catch (Exception e) { + ActiveMQJournalLogger.LOGGER.errorPushingFile(e); + fileFactory.onIOError(e, "unable to open ", null); } } }; @@ -504,8 +502,7 @@ public class JournalFilesRepository { } if (nextFile == null) { - - logger.debug("Could not get a file in " + journalFileOpenTimeout + " seconds, it will retry directly, without an executor"); + ActiveMQJournalLogger.LOGGER.cantOpenFileTimeout(journalFileOpenTimeout); try { nextFile = takeFile(true, true, true, false); } catch (Exception e) { diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/journal/ActiveMQJournalLogger.java b/artemis-journal/src/main/java/org/apache/activemq/artemis/journal/ActiveMQJournalLogger.java index fdd9eb1667..53ba9f1c3b 100644 --- a/artemis-journal/src/main/java/org/apache/activemq/artemis/journal/ActiveMQJournalLogger.java +++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/journal/ActiveMQJournalLogger.java @@ -284,4 +284,8 @@ public interface ActiveMQJournalLogger extends BasicLogger { @LogMessage(level = Logger.Level.WARN) @Message(id = 144008, value = "*******************************************************************************************************************************\nFile {0}: was moved under attic, please review it and remove it.\n*******************************************************************************************************************************", format = Message.Format.MESSAGE_FORMAT) void movingFileToAttic(String fileName); + + @LogMessage(level = Logger.Level.WARN) + @Message(id = 144009, value = "Could not get a file in {0} seconds, System will retry the open but you may see increased latency in your system", format = Message.Format.MESSAGE_FORMAT) + void cantOpenFileTimeout(long timeout); } diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/JournalImplTestBase.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/JournalImplTestBase.java index 1a5c86624f..34b2d9af7e 100644 --- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/JournalImplTestBase.java +++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/JournalImplTestBase.java @@ -38,6 +38,7 @@ import org.apache.activemq.artemis.core.journal.TestableJournal; import org.apache.activemq.artemis.core.journal.impl.JournalFile; import org.apache.activemq.artemis.core.journal.impl.JournalImpl; import org.apache.activemq.artemis.core.journal.impl.JournalReaderCallback; +import org.apache.activemq.artemis.logs.AssertionLoggerHandler; import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.utils.ReusableLatch; import org.apache.activemq.artemis.utils.collections.SparseArrayLinkedList; @@ -48,6 +49,20 @@ import org.junit.Before; public abstract class JournalImplTestBase extends ActiveMQTestBase { + @Before + public void startLogger() { + AssertionLoggerHandler.startCapture(); + } + + @After + public void stopLogger() { + try { + Assert.assertFalse(AssertionLoggerHandler.findText("AMQ144009")); + } finally { + AssertionLoggerHandler.stopCapture(); + } + } + private static final Logger log = Logger.getLogger(JournalImplTestBase.class); protected List records = new LinkedList<>();