CZT
2023-11-27 c206acfaedc69c390fb67daa81bc686f58a212ef
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package com.ld.igds.mq;
 
import com.ld.igds.io.constant.ProtocolEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
 
/**
 * 消息队列信息发布入口
 */
@Component
public class RedisPublishService {
 
    @Autowired
    private RedisTemplate<String, Object> redisTemplate;
 
    public void publish(String topic, String msg) {
 
        if (null == msg) return;
 
        if (null == topic) topic = ProtocolEnum.TCP_DEFAULT.getCode();
 
        redisTemplate.convertAndSend(topic, msg);
    }
}