package space.nstart.pcp_tgu_service.integration.kafka

import org.springframework.kafka.annotation.KafkaListener
import org.springframework.stereotype.Component
import space.nstart.pcp_tgu_service.config.TopicsProperties
import space.nstart.pcp_tgu_service.dto.StationParamsChangedMessage
import space.nstart.pcp_tgu_service.service.HandleStationParamsChangedUseCase

/**
 * Kafka consumer события об изменении параметров станций; запускает перезапрос ЗРВ.
 */
@Component
class StationParamsChangedConsumer(
    val topicsProperties: TopicsProperties,
    private val handleStationParamsChangedUseCase: HandleStationParamsChangedUseCase
) {
    @KafkaListener(
        topics = ["#{__listener.topicsProperties.stationParamsChanged}"],
        groupId = "\${spring.kafka.consumer.group-id}"
    )
    fun consume(message: StationParamsChangedMessage) {
        handleStationParamsChangedUseCase.handle(message)
    }
}
