ARTEMIS-4726 removing scheduled msg from q via mngmnt can cause negative msg count

This commit is contained in:
Justin Bertram 2024-04-17 17:01:25 -05:00
parent f64d918406
commit 1ee3e884b7
2 changed files with 18 additions and 1 deletions

View File

@ -178,7 +178,6 @@ public class ScheduledDeliveryHandlerImpl implements ScheduledDeliveryHandler {
ref.acknowledge(tx);
iter.remove();
notifyScheduledReferencesUpdated();
metrics.decrementMetrics(ref);
return ref;
}
}

View File

@ -543,6 +543,24 @@ public class ScheduledMessageTest extends ActiveMQTestBase {
session.close();
}
@Test
public void testManagementDeleteById() throws Exception {
try (ClientSessionFactory sessionFactory = createSessionFactory(locator)) {
ClientSession session = sessionFactory.createSession(false, false, false);
session.createQueue(new QueueConfiguration(atestq));
ClientProducer producer = session.createProducer(atestq);
ClientMessage messageToSend = session.createMessage(true);
messageToSend.putLongProperty(Message.HDR_SCHEDULED_DELIVERY_TIME, System.currentTimeMillis() + 999_999_999);
producer.send(messageToSend);
session.commit();
}
QueueControl queueControl = (QueueControl) server.getManagementService().getResource(ResourceNames.QUEUE + atestq);
assertEquals(1, queueControl.getMessageCount());
assertTrue(queueControl.removeMessage((long) queueControl.listScheduledMessages()[0].get("messageID")));
assertEquals(0, queueControl.getMessageCount());
}
@Test
public void testManagementDeliveryByFilter() throws Exception {
final String propertyValue = RandomUtil.randomString();