public class Async<T> extends Object implements Runnable
What is the point ? Send many message using a best effort strategy using some third party API that is not really non blocking. You can then decide to discard the messages or do something on your own but not put your main threads at risk.
The usage is straightrorward:
async = new Async(1000, "kafka-reporter", consumer);
...
if (!async.add("some string")) {
// it could not be processed
}
}
public Async(int size, String name, Consumer<T> accepted)
size
- the max queue size. If more than that number of items are enquued you
will fail adding more.name
- the name of the underlying threadconsumer
- the consumer in charge of performing a blocking or possibly slow operationCopyright © 2014–2022. All rights reserved.