This test uses amqutil, a general-purpose JMS test client:
https://github.com/kevinboone/amqutil
The "--qpid" argument in the examples below selects the use of Qpid JMS (AMQP). I am currently using version 0.55.0.
1. Clean broker message store (7.9)
2. Set up LVQ as follows in broker.xml:
<address name="foo">
<multicast>
<queue name="bar"
last-value-key="MESSAGE_KEY" non-destructive="true"/>
</multicast>
</address>
3. Start broker
4. Publish 10 numbered messages (values will be 0..9) with property MESSAGE_KEY of the same value:
$ amqutil publish 10 --qpid --destination foo --numbered --properties MESSAGE_KEY=1000
5. Consume as many messages as possible:
$ amqutil subscribe 100 --destination foo::bar --qpid --format text
...
ID:fcb3fc8b-bfd6-4a71-9b82-7021fcee1d64:1:1:1-10 TextMessage
JmsTextMessage
{ org.apache.qpid.jms.provider.amqp.message.AmqpJmsTextMessageFacade@1cf6d1be }
9
Since message are numbered 0...9, it is correct that the message with body "9" is retrieved, as it is the last value.
6. Publish 10 nunbered messages again (same numbering)
$ amqutil publish 10 --qpid --destination foo --numbered --properties MESSAGE_KEY=1000
5. Consume as many messages as possible:
$ amqutil subscribe 100 --destination foo::bar --qpid --format text
ID:ce6d3002-8f24-40b2-9abf-40fd8837da78:1:1:1-10 TextMessage
JmsTextMessage { org.apache.qpid.jms.provider.amqp.message.AmqpJmsTextMessageFacade@1cf6d1be }
9
ID:ce6d3002-8f24-40b2-9abf-40fd8837da78:1:1:1-10 TextMessage
JmsTextMessage
{ org.apache.qpid.jms.provider.amqp.message.AmqpJmsTextMessageFacade@663c9e7a }
9
Note that the message with body "9" is received twice.
6. publish one more message. The body will be numbered 0
$ amqutil publish 1 --qpid --destination foo --numbered --properties MESSAGE_KEY=1000
7. Consume messages
$ amqutil subscribe 100 --destination foo::bar --qpid --format text
ID:132d7d04-74c0-41eb-89df-2c07e94b45f0:1:1:1-1 TextMessage
JmsTextMessage { org.apache.qpid.jms.provider.amqp.message.AmqpJmsTextMessageFacade@1cf6d1be }
0
ID:132d7d04-74c0-41eb-89df-2c07e94b45f0:1:1:1-1 TextMessage
JmsTextMessage { org.apache.qpid.jms.provider.amqp.message.AmqpJmsTextMessageFacade@663c9e7a }
0
Again the message with key "1000" is duplicated; but the duplicate is the same value. That is, the consumer always seems to get the last value published, but it might get it more than once.