@ -58,6 +58,7 @@ import org.thingsboard.server.queue.TbQueueResponseTemplate;
import org.thingsboard.server.queue.common.TbProtoQueueMsg ;
import org.thingsboard.server.queue.common.consumer.PartitionedQueueConsumerManager ;
import org.thingsboard.server.queue.discovery.QueueKey ;
import org.thingsboard.server.queue.discovery.TopicService ;
import org.thingsboard.server.queue.discovery.event.PartitionChangeEvent ;
import org.thingsboard.server.queue.edqs.EdqsComponent ;
import org.thingsboard.server.queue.edqs.EdqsConfig ;
@ -88,6 +89,7 @@ public class EdqsProcessor implements TbQueueHandler<TbProtoQueueMsg<ToEdqsMsg>,
private final EdqsRepository repository ;
private final EdqsConfig config ;
private final EdqsPartitionService partitionService ;
private final TopicService topicService ;
private final ConfigurableApplicationContext applicationContext ;
private final EdqsStateService stateService ;
@ -123,7 +125,7 @@ public class EdqsProcessor implements TbQueueHandler<TbProtoQueueMsg<ToEdqsMsg>,
eventConsumer = PartitionedQueueConsumerManager . < TbProtoQueueMsg < ToEdqsMsg > > create ( )
. queueKey ( new QueueKey ( ServiceType . EDQS , config . getEventsTopic ( ) ) )
. topic ( config . getEventsTopic ( ) )
. topic ( topicService . buildTopicName ( config . getEventsTopic ( ) ) )
. pollInterval ( config . getPollInterval ( ) )
. msgPackProcessor ( ( msgs , consumer , config ) - > {
for ( TbProtoQueueMsg < ToEdqsMsg > queueMsg : msgs ) {
@ -164,9 +166,9 @@ public class EdqsProcessor implements TbQueueHandler<TbProtoQueueMsg<ToEdqsMsg>,
try {
Set < TopicPartitionInfo > newPartitions = event . getNewPartitions ( ) . get ( new QueueKey ( ServiceType . EDQS ) ) ;
stateService . process ( withTopic ( newPartitions , config . getStateTopic ( ) ) ) ;
stateService . process ( withTopic ( newPartitions , topicService . buildTopicName ( config . getStateTopic ( ) ) ) ) ;
// eventsConsumer's partitions are updated by stateService
responseTemplate . subscribe ( withTopic ( newPartitions , config . getRequestsTopic ( ) ) ) ; // TODO: we subscribe to partitions before we are ready. implement consumer-per-partition version for request template
responseTemplate . subscribe ( withTopic ( newPartitions , topicService . buildTopicName ( config . getRequestsTopic ( ) ) ) ) ; // TODO: we subscribe to partitions before we are ready. implement consumer-per-partition version for request template
Set < TopicPartitionInfo > oldPartitions = event . getOldPartitions ( ) . get ( new QueueKey ( ServiceType . EDQS ) ) ;
if ( CollectionsUtil . isNotEmpty ( oldPartitions ) ) {