Last active
July 24, 2018 19:59
-
-
Save schroedermatt/3029cb714665b4813f1715a0f464fc62 to your computer and use it in GitHub Desktop.
Spring Kafka Config blog
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Configuration | |
| public class TopicAdministrator { | |
| private final TopicConfigurations configurations; | |
| private final GenericWebApplicationContext context; | |
| public TopicAdministrator(TopicConfigurations configurations, GenericWebApplicationContext genericContext) { | |
| this.configurations = configurations; | |
| this.context = genericContext; | |
| } | |
| @PostConstruct | |
| public void createTopics() { | |
| configurations | |
| .getTopics() | |
| .ifPresent(this::initializeBeans); | |
| } | |
| private void initializeBeans(List<TopicConfiguration> topics) { | |
| topics.forEach(t -> { | |
| context.registerBean(t.getName(), NewTopic.class, t::toNewTopic); | |
| }); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment