package org.dromara.mqtt;

import lombok.RequiredArgsConstructor;
import org.dromara.mqtt.config.properties.MqttProperties;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
@RequiredArgsConstructor
public class MqttCommandRetryTask {

    private final MqttCommandAckService ackService;
    private final MqttProperties mqttProperties;

    @Scheduled(fixedDelayString = "${mqtt.command-ack.scan-interval-ms:5000}")
    public void retryExpiredCommands() {
        if (mqttProperties.getCommandAck().isEnabled()) {
            ackService.retryExpiredCommands();
        }
    }
}
