io.paradoxical.cassieq.clustering.eventing.HazelcastEventBus Maven / Gradle / Ivy
package io.paradoxical.cassieq.clustering.eventing;
import com.godaddy.logging.Logger;
import com.google.inject.Inject;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.core.Message;
import com.hazelcast.core.MessageListener;
import java.util.Objects;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import static com.godaddy.logging.LoggerFactory.getLogger;
public class HazelcastEventBus implements EventBus {
private final ExecutorService executorService = Executors.newCachedThreadPool();
private static final Logger logger = getLogger(HazelcastEventBus.class);
private final HazelcastInstance hazelcastInstance;
private final String topicName = "events";
@Inject
public HazelcastEventBus(HazelcastInstance instance) {
hazelcastInstance = instance;
}
@Override
public void publish(final T event) {
hazelcastInstance.getTopic(topicName).publish(event);
}
@Override
public String register(Class eventType, final EventListener listener) {
try {
return hazelcastInstance.getTopic(topicName).addMessageListener(new MessageListener
© 2015 - 2025 Weber Informatics LLC | Privacy Policy