currently I am using the guava EventBus approach in my application. The listener tries to do some work and if it fails, the event should be back in the bus and resent.
My question is: what if my application is going down (performing a shut down)? Will it send the remaining events in the bus?
I am looking for some approach, such as implemented in ActiveMQ shut down hoow
should the broker install a shutdown hook so that it can properly shut itself down on a JVM kill
Unfortunately I didn´t find something similar in EventBus guava.
The standard Guava EventBus
is synchron, it has no internal Thread
or something like that. If the thread that calls post(Object event)
dies, the EventBus stops delivering events (because it uses the caller's Thread).
The AsyncEventBus
on the other hand takes an Executor
(from the java.util.concurrent
package) during construction which is used to dispatch events. In this case it depends what executor implementation you use. For example a ThreadPoolExecutor
would need a shutdownNow()
call to stop delivering messages.