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 db9e2cb7d3..7d093664ac 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 @@ -1777,10 +1777,6 @@ public class ServerSessionImpl implements ServerSession, FailureListener { final boolean direct, boolean noAutoCreateQueue, RoutingContext routingContext) throws Exception { - if (AuditLogger.isMessageEnabled()) { - AuditLogger.coreSendMessage(getUsername(), messageParameter.toString(), routingContext); - } - final Message message = LargeServerMessageImpl.checkLargeMessage(messageParameter, storageManager); if (server.hasBrokerMessagePlugins()) { @@ -1806,6 +1802,10 @@ public class ServerSessionImpl implements ServerSession, FailureListener { message.setMessageID(id); } + if (AuditLogger.isMessageEnabled()) { + AuditLogger.coreSendMessage(getUsername(), message.toString(), routingContext); + } + SimpleString address = message.getAddressSimpleString(); if (defaultAddress == null && address != null) { diff --git a/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/logging/AuditLoggerTest.java b/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/logging/AuditLoggerTest.java index dd77614cb9..4bb95cab33 100644 --- a/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/logging/AuditLoggerTest.java +++ b/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/logging/AuditLoggerTest.java @@ -207,6 +207,7 @@ public class AuditLoggerTest extends SmokeTestBase { Wait.waitFor(() -> addressControl.getMessageCount() == 2); Assert.assertEquals(2, addressControl.getMessageCount()); + checkAuditLogRecord(false, "messageID=0"); checkAuditLogRecord(true, "sending a message"); checkAuditLogRecord(true, uniqueStr); checkAuditLogRecord(true, "Hello2");