HostInfo applicationServer,
String usersInputTopic,
String rankingInputTopic,
HostInfo applicationServer,
String usersInputTopic,
String rankingInputTopic,
streams = new KafkaStreams(topology, props);
hostInfo = applicationServer;
streams = new KafkaStreams(topology, props);
hostInfo = applicationServer;
}
static Topology buildTopology(
String usersInputTopic,
String rankingInputTopic,
}
static Topology buildTopology(
String usersInputTopic,
String rankingInputTopic,
{
StreamsBuilder builder = new StreamsBuilder();
KTable<String, User> users = builder
.stream(usersInputTopic)
{
StreamsBuilder builder = new StreamsBuilder();
KTable<String, User> users = builder
.stream(usersInputTopic)
- .toTable(Materialized.with(null, new JsonSerde().copyWithType(User.class)));
+ .toTable(
+ Materialized
+ .<String, User>as(userStoreSupplier)
+ .withKeySerde(Serdes.String())
+ .withValueSerde(new JsonSerde().copyWithType(User.class)));
.withValueSerde(new JsonSerde().copyWithType(UserRanking.class)));
Topology topology = builder.build();
.withValueSerde(new JsonSerde().copyWithType(UserRanking.class)));
Topology topology = builder.build();
- KeyQueryMetadata metadata = streams.queryMetadataForKey(STORE_NAME, username, Serdes.String().serializer());
+ KeyQueryMetadata metadata = streams.queryMetadataForKey(RANKING_STORE_NAME, username, Serdes.String().serializer());
HostInfo activeHost = metadata.activeHost();
log.debug("Local store for {}: {}, {}:{}", username, metadata.partition(), activeHost.host(), activeHost.port());
HostInfo activeHost = metadata.activeHost();
log.debug("Local store for {}: {}, {}:{}", username, metadata.partition(), activeHost.host(), activeHost.port());