@ -21,6 +21,7 @@ import org.apache.kafka.clients.consumer.ConsumerConfig;
import org.apache.kafka.clients.consumer.ConsumerRecord ;
import org.apache.kafka.clients.consumer.ConsumerRecords ;
import org.apache.kafka.clients.consumer.KafkaConsumer ;
import org.springframework.util.StopWatch ;
import org.thingsboard.server.queue.TbQueueAdmin ;
import org.thingsboard.server.queue.TbQueueMsg ;
import org.thingsboard.server.queue.common.AbstractTbQueueConsumerTemplate ;
@ -82,7 +83,16 @@ public class TbKafkaConsumerTemplate<T extends TbQueueMsg> extends AbstractTbQue
@Override
protected List < ConsumerRecord < String , byte [ ] > > doPoll ( long durationInMillis ) {
StopWatch stopWatch = new StopWatch ( ) ;
stopWatch . start ( ) ;
log . trace ( "poll topic {} maxDuration {}" , getTopic ( ) , durationInMillis ) ;
ConsumerRecords < String , byte [ ] > records = consumer . poll ( Duration . ofMillis ( durationInMillis ) ) ;
stopWatch . stop ( ) ;
log . trace ( "poll topic {} took {}ms" , getTopic ( ) , stopWatch . getTotalTimeMillis ( ) ) ;
if ( records . isEmpty ( ) ) {
return Collections . emptyList ( ) ;
} else {