Currently, the bundler thread in TransferQueueBundler removes messages from the queue one by one:
while(null != (msg=queue.poll())) { long size=msg.size(); if(count + size >= transport.getMaxBundleSize()) sendBundledMessages(); addMessage(msg, size); }
This is inefficient, as we need to acquire the lock on ArrayBlockingQueue every time. ArrayBlockingQueue.drainTo() should be used instead, to remove as many messages as are in the queue with one lock acquisition.