jbertram commented on code in PR #6047:
URL: https://github.com/apache/activemq-artemis/pull/6047#discussion_r2518795048
##########
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();
Review Comment:
Fixed.
##########
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:
Changed.
##########
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:
Updated.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact