package com.xinda.mq.redischannel.consumer;

import com.xinda.common.constant.XinDaConstant;
import com.xinda.common.core.device.DeviceAndProtocol;
import com.xinda.common.core.mq.MQSendMessageBo;
import com.xinda.common.exception.ServiceException;
import com.xinda.iot.service.IDeviceService;
import com.xinda.mq.service.IMqttMessagePublish;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import java.util.Optional;

/**
 * 指令(服务)下发处理类
 *
 * @author gsb
 * @date 2022/10/11 8:17
 */
@Slf4j
@Component
public class FunctionInvokeConsumer {


    @Autowired
    private IMqttMessagePublish functionSendService;

    @Async(XinDaConstant.TASK.FUNCTION_INVOKE_TASK)
    public void handler(MQSendMessageBo bo) {
        try {
            functionSendService.funcSend(bo);
        } catch (Exception e) {
            log.error("=>服务下发异常", e);
        }
    }
}
