ARTEMIS-3925 LVQ pruning nulls

Messages without a last-value property sent to an LVQ are being pruned
rather than just passing through. Only messages with a non-null
last-value property should be subject to pruning.
This commit is contained in:
Justin Bertram 2022-08-11 11:50:00 -05:00
parent 520088b8c6
commit d158e7eff0
No known key found for this signature in database
GPG Key ID: F41830B875BB8633
2 changed files with 25 additions and 0 deletions

View File

@ -224,6 +224,9 @@ public class LastValueQueue extends QueueImpl {
if (current == ref) {
currentLastValue = true;
}
} else {
// if the ref has no last value
return true;
}
return currentLastValue;
}

View File

@ -140,6 +140,28 @@ public class LVQTest extends ActiveMQTestBase {
Assert.assertEquals(m.getBodyBuffer().readString(), "m4");
}
@Test
public void testMultipleMessagesWithoutLastValue() throws Exception {
ClientProducer producer = clientSession.createProducer(address);
ClientMessage m1 = createTextMessage(clientSession, "message1");
ClientMessage m2 = createTextMessage(clientSession, "message2");
producer.send(m1);
producer.send(m2);
Wait.assertEquals(2L, () -> server.locateQueue(qName1).getMessageCount(), 2000, 100);
ClientConsumer consumer = clientSession.createConsumer(qName1);
clientSession.start();
ClientMessage m = consumer.receive(1000);
Assert.assertNotNull(m);
m.acknowledge();
Assert.assertEquals("message1", m.getBodyBuffer().readString());
m = consumer.receive(1000);
Assert.assertNotNull(m);
m.acknowledge();
Assert.assertEquals("message2", m.getBodyBuffer().readString());
}
@Test
public void testMultipleRollback() throws Exception {
AddressSettings qs = new AddressSettings();