private final String topic;
private final Producer<String, AbstractMessageTo> producer;
private final Consumer<String, AbstractMessageTo> consumer;
+ private final Duration pollingInterval;
private final int numShards;
private final String[] shardOwners;
private final long[] currentOffset;
String topic,
Producer<String, AbstractMessageTo> producer,
Consumer<String, AbstractMessageTo> infoChannelConsumer,
+ Duration pollingInterval,
+ int numShards,
URI instanceUri)
{
log.debug(
this.producer = producer;
this.chatRoomInfo = new HashMap<>();
- this.numShards = consumer
- .partitionsFor(topic)
- .size();
+ this.pollingInterval = pollingInterval;
+
+ this.numShards = numShards;
this.shardOwners = new String[numShards];
this.currentOffset = new long[numShards];
this.nextOffset = new long[numShards];
{
try
{
- ConsumerRecords<String, AbstractMessageTo> records = consumer.poll(Duration.ofMinutes(1));
+ ConsumerRecords<String, AbstractMessageTo> records = consumer.poll(pollingInterval);
log.debug("Fetched {} messages", records.count());
for (ConsumerRecord<String, AbstractMessageTo> record : records)
{