jiazx0107@163.com
2023-05-17 620eab6cca2bc9ef9ea6d3067a0a5ba1deadbd1c
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);
    }
}