import jakarta.annotation.PreDestroy;
import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.common.serialization.Serdes;
-import org.apache.kafka.streams.KafkaStreams;
-import org.apache.kafka.streams.KeyQueryMetadata;
-import org.apache.kafka.streams.StoreQueryParameters;
-import org.apache.kafka.streams.StreamsBuilder;
+import org.apache.kafka.streams.*;
import org.apache.kafka.streams.kstream.KStream;
import org.apache.kafka.streams.kstream.KTable;
import org.apache.kafka.streams.kstream.Materialized;
String usersInputTopic,
String rankingInputTopic,
ObjectMapper mapper)
+ {
+ Topology topology = buildTopology(usersInputTopic, rankingInputTopic, mapper);
+ streams = new KafkaStreams(topology, props);
+ hostInfo = applicationServer;
+ storeParameters = StoreQueryParameters.fromNameAndType(STORE_NAME, QueryableStoreTypes.keyValueStore());;
+ this.mapper = mapper;
+ }
+
+ static Topology buildTopology(
+ String usersInputTopic,
+ String rankingInputTopic,
+ ObjectMapper mapper)
{
StreamsBuilder builder = new StreamsBuilder();
})
.toTable(Materialized.as(STORE_NAME));
- streams = new KafkaStreams(builder.build(), props);
- hostInfo = applicationServer;
- storeParameters = StoreQueryParameters.fromNameAndType(STORE_NAME, QueryableStoreTypes.keyValueStore());;
- this.mapper = mapper;
+ Topology topology = builder.build();
+ log.info("\n\n{}", topology.describe());
+
+ return topology;
}
public Optional<URI> getRedirect(String username)