public void postEvent(final String topic, Map<String, String> payload) {
final Map<String, String> eventPayload = new HashMap<>(payload);
for (final EventListener listener : m_listeners) {
ScheduledExecutorService executor = getExecutorService();
if (executor.isShutdown()) {
logWarning("Cannot post event, executor is shut down!");
return;
}
executor.submit(new Runnable() {
@Override
public void run() {
try {
listener.handle(topic, eventPayload);
}
catch (Exception e) {
logWarning("Exception while posting event", e);
}
}
});
}
}
|