If you have a distributed environment, use Akka .
Otherwise, you have several options.
Guava has an EvenBus . Guava would be my choice because it has become one of the main libraries that use Java projects like apache commons, slf4j, etc.
A Google search for the "java event library" shows a few more options.
Otherwise, write a class that contains subscribers and will send them events as they arrive. Easy but careful with concurrency.
Daniel Nuriyev
source share