Its possible to get a broker (that is part of a full mesh network) into a state where a small amount of messages seem to be stuck on the broker's queue and don't get dispatched to any consumer.
When trying to browse the queue using JMX no messages are returned but the JMX QueueSize statistic reports one or a few messages.
In addition (as JDBC persistence is used) the corresponding database has the same amount of messages still residing in the activemq_msgs table.This problem is tricky to reproduce. However the attached JUnit test should help. It may not reproduce it on every test run though.
The broker's network configuration already uses replayWhenNoConsumers=true, enableAudit=false, networkTTL=9999, optimizedDispatch=true so that messages can freely get passed around in the network.
The above three settings should already avoid messages getting stuck on one broker or getting discarded as duplicates. Still there seems to be another problem.