{
private final Consumer<String, MessageTo> consumer;
private final String topic;
- private final long[] offsets;
- private final MessageHandler[] handlers;
+ // private final long[] offsets; Erst mal immer alles neu einlesen
private final Map<UUID, ChatRoom>[] chatrooms;
log.debug("Creating KafkaChatHomeService");
this.consumer = consumer;
this.topic = topic;
- this.offsets = new long[numShards];
- this.handlers = new MessageHandler[numShards];
- for (int i=0; i< numShards; i++)
- {
- this.offsets[i] = 0l;
- this.handlers[i] = new MessageHandler(new TopicPartition(topic, i));
- }
+ // this.offsets = new long[numShards];
+ // for (int i=0; i< numShards; i++)
+ // {
+ // this.offsets[i] = 0l;
+ // }
this.chatrooms = new Map[numShards];
}
}
int partition = tp.partition();
- long unseenOffset = offsets[partition];
-
- log.info("Reading partition {} from {} -> {}", partition, unseenOffset, currentOffset);
+ long unseenOffset = 0; // offsets[partition];
+
+ log.info(
+ "Loading messages from partition {}: start-offset={} -> current-offset={}",
+ partition,
+ unseenOffset,
+ currentOffset);
+
+ consumer.seek(tp, unseenOffset);
+ chatrooms[partition]
+ .values()
+ .stream()
handlers[partition] = new ChatRoomLoadingMessageHandlingStrategy(tp, currentOffset, unseenOffset);
});
}