I have an application that generates millions of events and sends those events to a server and receives Futures for each event. In order to prevent the application from running out of memory, I put those Futures in a ArrayBlockingQueue
and that queue is processed by another thread.
My application sends those events faster than it can process those Futures and hence the application slows down quite a bit.
What is the best way to handle these Futures?