package cn.iocoder.yudao.module.system.mq.consumer.remote;

import cn.iocoder.yudao.module.system.mq.message.remote.RemoteSendMessage;
import cn.iocoder.yudao.module.system.service.remote.RemoteControllerInformationService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
@Slf4j
public class RemoteControllerConsumer {

    @Resource
    private RemoteControllerInformationService controllerInformationService;

    @EventListener
    @Async // Spring Event 默认在 Producer 发送的线程，通过 @Async 实现异步
    public void onMessage(RemoteSendMessage message) {
        log.info("远遥模块事件收到的消息 : {}", message);
        controllerInformationService.repeatedTransmissionDisconnect(message);
    }

}
