For some reason in the following code, destinationSource.getQueues()
is returning a CopyOnWriteArraySet
instead of a simple Set
. This is a
I had the same issue with getting all queues from a connection. Whenever i got the queues from the DestinationSource and then iterated afterwards (foreach) over this set, i got different number of queues (In the iteration loop i always get more queues than in the initial set).
DestinationSource ds = connection.getDestinationSource();
Set queues = ds.getQueues();
log.debug("Found '" + queues.size() + "' queues");
for (ActiveMQQueue queue : queues) {...}
Then, i added a listener to the destination source like this
DestinationSource ds = connection.getDestinationSource();
Set queues = ds.getQueues();
// Add listener:
ds.setDestinationListener(event -> event.hashCode());
log.debug("Found '" + queues.size() + "' queues");
for (ActiveMQQueue queue : queues) {...}
From now on, i always get the right number of queues and can iterate over the complete set.
Allthough, i don't really know why ;)