package com.tashow.cloud.app.task;
import com.tashow.cloud.app.model.MqMessageRecord;
import com.tashow.cloud.app.service.impl.BuriedPointFailRecordService;
import com.tashow.cloud.mq.retry.AbstractMessageRetryTask;
import com.tashow.cloud.mq.retry.MessageRetryService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * 埋点消息重试定时任务
 */
@Slf4j
@Component
@RequiredArgsConstructor
public class BuriedPointRetryTask extends AbstractMessageRetryTask<MqMessageRecord> {

    private final BuriedPointFailRecordService buriedPointFailRecordService;

    /**
     * 定时重试失败消息
     * 每天凌晨执行一次
     */
    @Scheduled(cron = "0 0 0 * * ?")
   // @Scheduled(cron = "0/10 * * * * ?")
    public void execute() {
        retryFailedMessages();
    }

    @Override
    protected MessageRetryService<MqMessageRecord> getMessageRetryService() {
        return buriedPointFailRecordService;
    }
    @Override
    protected Integer getRecordId(MqMessageRecord record) {
        return record.getId();
    }


} 