Skip to content

Instantly share code, notes, and snippets.

/PublisherImpl.java
Created Feb 8, 2018

Embed
What would you like to do?
class PublisherImpl implements Publisher {
private Map<Topic, Subscriber[]> subscribers;
private KafkaClient kafkaClient;
public Publisher(Map<Topic, Subscriber[]> subscribers, KafkaClient kafkaClient) {
this.subscribers = subscribers;
this.kafkaClient = kafkaClient;
}
public void publish(Message m) {
messageType = m.getType()
topic = new Topic(messageType);
subscribers.getOrDefault(topic, {}).forEach(subscriber -> subscriber.handle(m));
kafka.publish(messageType, m);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.