@Override
public void createTopic(Topic topic) {
groupRepository.ensureGroupExists(topic.getName().getGroupName());
String topicPath = paths.topicPath(topic.getName());
logger.info("Creating topic for path {}", topicPath);
try {
zookeeper.inTransaction()
.create().forPath(topicPath, mapper.writeValueAsBytes(topic))
.and()
.create().forPath(paths.subscriptionsPath(topic.getName()))
.and().commit();
} catch (KeeperException.NodeExistsException ex) {
throw new TopicAlreadyExistsException(topic.getName(), ex);
} catch (Exception ex) {
throw new InternalProcessingException(ex);
}
}