package com.ruoyi.interfaces.redisListener;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.redis.connection.Message;
import org.springframework.data.redis.connection.MessageListener;

import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;

/**
 * @author LinQiLong
 * @date 4/6/2022 3:31 PM
 */
public class InterfaceLogMsgListener implements MessageListener {

    private Logger log = LoggerFactory.getLogger(InterfaceLogMsgListener.class);

    @Override
    public void onMessage(Message message, byte[] bytes) {
        log.info("============>>>>> onMessage");
        byte[] channel = message.getChannel();
        byte[] body = message.getBody();
        String title = new String(channel, StandardCharsets.UTF_8);
        String content = new String(body, StandardCharsets.UTF_8);
        log.info("消息频道名称：" + title);
        log.info("消息内容是:" + content);
    }
}
