While delivering messages, the AbstractDispatcher generates 2 copies of the registered handlers collection in order to iterate them. We have found a 30% increment throughput after replacing the structure used for storing handlers. This new structure allows iteration, and concurrent modification (if any) of the collection, and avoids the need of copying it everytime a message needs to be dispatched by a MessageChannel.
I am attaching the OrderedAwareCopyOnWriterArrayList and the AbstractDisptacher which uses it.
This implementation improves the most common usage of the registered handlers collection (iteration), and as drawback, handler registration takes O(n). We tried to keep compatibility with the previous implementation, therefore we need to add a handler to the list iif it is not already in it. If this is not a requirement and it was actually a side effect of using a set as base structure, we can just add the new handler and reduce the Order from n to ~1.