use of io.micronaut.context.annotation.Context in project micronaut-kafka by micronaut-projects.
the class KafkaStreamsFactory method kafkaStreams.
/**
* Builds the default {@link KafkaStreams} bean from the configuration and the supplied {@link ConfiguredStreamBuilder}.
*
* @param name The configuration name
* @param builder The builder
* @param kStreams The KStream definitions
* @return The {@link KafkaStreams} bean
*/
@EachBean(ConfiguredStreamBuilder.class)
@Context
KafkaStreams kafkaStreams(@Parameter String name, ConfiguredStreamBuilder builder, KStream<?, ?>... kStreams) {
Topology topology = builder.build(builder.getConfiguration());
KafkaStreams kafkaStreams = new KafkaStreams(topology, builder.getConfiguration());
eventPublisher.publishEvent(new BeforeKafkaStreamStart(kafkaStreams, kStreams));
streams.put(kafkaStreams, builder);
if (LOG.isDebugEnabled()) {
LOG.debug("Initializing Application {} with topology:\n{}", name, topology.describe().toString());
}
kafkaStreams.start();
eventPublisher.publishEvent(new AfterKafkaStreamsStart(kafkaStreams, kStreams));
return kafkaStreams;
}
Aggregations