package com.ruoyi.business.data.listener;

import com.ruoyi.common.core.redis.RedisCache;
import org.eclipse.paho.client.mqttv3.IMqttMessageListener;
import org.eclipse.paho.client.mqttv3.MqttMessage;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author Duke_yzl
 * @date 20230701.01
 * @describe：
 */
@Component
public class MqttMessageListener implements IMqttMessageListener {

    @Resource
    private RedisCache redisCache;
    @Override
    public void messageArrived(String topic, MqttMessage mqttMessage) throws Exception {
        System.out.println("监听器");
        System.out.println("主题："+ topic);
        System.out.println("消息："+ new String(mqttMessage.getPayload()));
//        redisCache.setCacheObject(topic,new String(mqttMessage.getPayload()),10*6, TimeUnit.SECONDS);
    }
}