[
https://issues.apache.org/jira/browse/ARTEMIS-4929?focusedWorklogId=991548&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-991548
]
ASF GitHub Bot logged work on ARTEMIS-4929:
-------------------------------------------
Author: ASF GitHub Bot
Created on: 13/Nov/25 16:52
Start Date: 13/Nov/25 16:52
Worklog Time Spent: 10m
Work Description: gemmellr commented on code in PR #6047:
URL: https://github.com/apache/activemq-artemis/pull/6047#discussion_r2524213425
##########
tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/logging/AuditLoggerTest.java:
##########
@@ -199,4 +202,34 @@ public void internalSend(String protocol, int messageSize)
throws Exception {
Wait.assertTrue(() -> findLogRecord(getAuditLog(), "is consuming a
message from"), 5000);
Wait.assertTrue(() -> findLogRecord(getAuditLog(), "acknowledged message
from"), 5000);
}
+
+ @Test
+ public void testExpiration() throws Exception {
+ final int EXPIRATION = 1000;
+ SimpleString address = RandomUtil.randomUUIDSimpleString();
+ SimpleString queue = RandomUtil.randomUUIDSimpleString();
+ final SimpleString expiryAddress = RandomUtil.randomUUIDSimpleString();
+ SimpleString expiryQueue = RandomUtil.randomUUIDSimpleString();
+
+ JMXConnector jmxConnector = getJmxConnector();
+ MBeanServerConnection mBeanServerConnection =
jmxConnector.getMBeanServerConnection();
+ String brokerName = "0.0.0.0"; // configured e.g. in broker.xml
<broker-name> element
+ ObjectNameBuilder objectNameBuilder =
ObjectNameBuilder.create(ActiveMQDefaultConfiguration.getDefaultJmxDomain(),
brokerName, true);
+
+ final ActiveMQServerControl serverControl =
MBeanServerInvocationHandler.newProxyInstance(mBeanServerConnection,
objectNameBuilder.getActiveMQServerObjectName(), ActiveMQServerControl.class,
false);
+
+ serverControl.addAddressSettings(address.toString(), new
AddressSettings().setExpiryAddress(expiryAddress).toJSON());
+
+
session.createQueue(QueueConfiguration.of(queue).setAddress(address).setDurable(false));
+
session.createQueue(QueueConfiguration.of(expiryQueue).setAddress(expiryAddress).setDurable(false));
+
+ ClientProducer producer = session.createProducer(address);
+ ClientMessage message = session.createMessage(false);
+ message.setExpiration(System.currentTimeMillis() + EXPIRATION);
+ producer.send(message);
+
+ Thread.sleep(EXPIRATION * 2);
+
+ Wait.assertTrue(() -> findLogRecord(getAuditLog(), "User
management@internal acknowledged message from"), 5000);
Review Comment:
You added the single period sleep, so it wont try when its known it
definitely wont have happened yet, which is good...but you also removed a
period from the Wait, so it remains as likely to sporadically fail as before
the change. Seems like it needs at least some more headroom to guard against
the 'takes [almost] 2 periods to expire' worst case, and any non-instantaneous
scheduling etc.
##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/QueueImpl.java:
##########
@@ -1733,8 +1734,16 @@ public void acknowledge(final Transaction tx, final
MessageReference ref, final
if (AuditLogger.isMessageLoggingEnabled()) {
// it's possible for the consumer to be null (e.g. acking the
message administratively)
final ServerSession session = consumer != null ?
server.getSessionByID(consumer.getSessionID()) : null;
- final Subject subject = session == null ? null :
session.getRemotingConnection().getSubject();
- final String remoteAddress = session == null ? null :
session.getRemotingConnection().getRemoteAddress();
+ final Subject subject;
+ final String remoteAddress;
+ if (session == null) {
+ subject = new Subject();
+ subject.getPrincipals().add(new UserPrincipal("management"));
+ remoteAddress = "internal";
Review Comment:
Think you might need to update what the test looks for again.
Issue Time Tracking
-------------------
Worklog Id: (was: 991548)
Time Spent: 1h (was: 50m)
> Incorrect logging for anonymous user message acknowledgement events
> -------------------------------------------------------------------
>
> Key: ARTEMIS-4929
> URL: https://issues.apache.org/jira/browse/ARTEMIS-4929
> Project: ActiveMQ Artemis
> Issue Type: Bug
> Affects Versions: 2.35.0
> Reporter: Aleksandr Milovidov
> Priority: Minor
> Labels: pull-request-available
> Time Spent: 1h
> Remaining Estimate: 0h
>
> When messages in the queue are expired, it is logged in the audit log with
> events:
> {noformat}
> AMQ601500: User admin(amq)@127.0.0.1:61979 sent a message CoreMessage ...
> AMQ601759: User [email protected]:61979 added acknowledgement of a message
> from TEST: ...
> AMQ601502: User [email protected]:61979 acknowledged message from TEST:
> ...{noformat}
> Source IP address and port in these events are the same like in previous
> events (in this example, send message event).
> How to reproduce:
> - create default Artemis instance
> - enable message audit logging in {{log4j2.properties}}
> - send one test message with 1 second expiry using 127.0.0.1 loopback address
> - wait some seconds for message expiry
> - send another test message with expiry using computer's IP address
> - wait some seconds for message expiry
> - check {{audit.log}} for message send and acknowledge events
> Example commands:
> {noformat}
> artemis producer --url=tcp://127.0.0.1:61616 --user=admin --password=admin
> --message-count=1 --msgttl=1000{noformat}
> {noformat}
> artemis producer --url=tcp://192.168.0.1:61616 --user=admin --password=admin
> --message-count=1 --msgttl=1000{noformat}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact