diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalImpl.java b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalImpl.java index 3043b9770e..5f31a2b216 100644 --- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalImpl.java +++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalImpl.java @@ -2207,7 +2207,11 @@ public class JournalImpl extends JournalBase implements TestableJournal, Journal */ @Override public long getMaxRecordSize() { - return Math.min(getFileSize(), fileFactory.getBufferSize()); + if (fileFactory.getBufferSize() == 0) { + return getFileSize(); + } else { + return Math.min(getFileSize(), fileFactory.getBufferSize()); + } } private void flushExecutor(Executor executor) throws InterruptedException { diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/StorageManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/StorageManager.java index ba32252990..6dc45c087e 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/StorageManager.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/StorageManager.java @@ -65,6 +65,11 @@ import org.apache.activemq.artemis.utils.IDGenerator; */ public interface StorageManager extends IDGenerator, ActiveMQComponent { + default long getMaxRecordSize() { + /** Null journal is pretty much memory */ + return Long.MAX_VALUE; + } + void criticalError(Throwable error); /** diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/AbstractJournalStorageManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/AbstractJournalStorageManager.java index 1c5a4c3c5d..3930334b78 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/AbstractJournalStorageManager.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/AbstractJournalStorageManager.java @@ -228,6 +228,12 @@ public abstract class AbstractJournalStorageManager extends CriticalComponentImp idGenerator = new BatchingIDGenerator(0, CHECKPOINT_BATCH_SIZE, this); } + + public long getMaxRecordSize() { + return messageJournal.getMaxRecordSize(); + } + + /** * Called during initialization. Used by implementations to setup Journals, Stores etc... * diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java index 781334192c..679312c4b9 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java @@ -1333,7 +1333,7 @@ public class ServerSessionImpl implements ServerSession, FailureListener { boolean noAutoCreateQueue) throws Exception { final Message message; - if ((msg.getEncodeSize() > storageManager.getMessageJournal().getMaxRecordSize()) && !msg.isLargeMessage()) { + if ((msg.getEncodeSize() > storageManager.getMaxRecordSize()) && !msg.isLargeMessage()) { message = messageToLargeMessage(msg); } else { message = msg;