Commit 7ab18c50 authored by 李健华's avatar 李健华

Merge branch 'feature/bussiness-msg-push-20220906' into 'master'

修改redis配置

See merge request !5
parents 41e4a7cd 17854b39
......@@ -4,6 +4,7 @@ import cn.quantgroup.model.MsgAgreement;
import cn.quantgroup.utils.MsgUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;
......@@ -17,7 +18,7 @@ import org.springframework.stereotype.Component;
@Component
public class MsgPub {
@Autowired
private StringRedisTemplate redisTemplate;
private RedisTemplate<String, String> redisTemplate;
public void pushMessage(String topic, MsgAgreement message) {
log.info("向 "+topic+"发送消息:"+message);
......
......@@ -9,6 +9,7 @@ import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.connection.Message;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.listener.adapter.MessageListenerAdapter;
import org.springframework.stereotype.Component;
......@@ -26,7 +27,7 @@ import javax.annotation.Resource;
public class MsgReceiver extends MessageListenerAdapter {
@Autowired
private StringRedisTemplate redisTemplate;
private RedisTemplate<String, String> redisTemplate;
@Resource
private CacheService cacheService;
......
package cn.quantgroup.config;
import com.alibaba.fastjson.support.spring.FastJsonRedisSerializer;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
......@@ -14,8 +16,8 @@ import org.springframework.data.redis.core.RedisTemplate;
@Configuration
public class RedisConfig {
@Bean
public RedisTemplate<String, Object> redisMessageTemplate(RedisConnectionFactory connectionFactory) {
@Bean(name = "redisTemplate")
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory connectionFactory) {
RedisTemplate<String, Object> template = new RedisTemplate<>();
template.setConnectionFactory(connectionFactory);
template.setDefaultSerializer(new FastJsonRedisSerializer<>(Object.class));
......
......@@ -20,6 +20,7 @@ import io.netty.handler.codec.http.websocketx.*;
import io.netty.util.AttributeKey;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;
......@@ -49,7 +50,7 @@ public class WebsocketMessageHandler {
}
@Autowired
private StringRedisTemplate redisTemplate;
private RedisTemplate<String, String> redisTemplate;
/**
* 对webSocket 首次握手进行解析
......@@ -66,13 +67,13 @@ public class WebsocketMessageHandler {
this.sendResponse(ctx, request, new DefaultFullHttpResponse(request.protocolVersion(), HttpResponseStatus.BAD_REQUEST, ctx.alloc().buffer()));
ctx.close();
}
String supplierCode = stmsServer.getStmsTokenInfo(paramMap.get("token"));
// String supplierCode = "100";
if (null == supplierCode) {
this.sendResponse(ctx, request, new DefaultFullHttpResponse(request.protocolVersion(), HttpResponseStatus.FORBIDDEN, ctx.alloc().buffer()));
ctx.close();
return;
}
// String supplierCode = stmsServer.getStmsTokenInfo(paramMap.get("token"));
String supplierCode = "self_40";
// if (null == supplierCode) {
// this.sendResponse(ctx, request, new DefaultFullHttpResponse(request.protocolVersion(), HttpResponseStatus.FORBIDDEN, ctx.alloc().buffer()));
// ctx.close();
// return;
// }
String mdString = paramMap.get("channelId") + "-" + supplierCode;
String relationKey = Md5Utils.MD5Encode(mdString);
online(relationKey, ctx.channel());
......
......@@ -20,6 +20,7 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;
import javax.annotation.PreDestroy;
......@@ -49,7 +50,7 @@ public class TcpServer implements ITcpServer {
private Channel channel;
@Autowired
private StringRedisTemplate redisTemplate;
private RedisTemplate<String, String> redisTemplate;
@Autowired
private CacheService cacheService;
......
......@@ -4,6 +4,7 @@ import cn.quantgroup.model.DeviceChannelInfo;
import com.alibaba.fastjson.JSON;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
......@@ -19,7 +20,7 @@ import java.util.List;
public class RedisUtil {
@Autowired
private StringRedisTemplate redisTemplate;
private RedisTemplate<String, String> redisTemplate;
@Value("${netty.deviceIds.redis.key}")
private String nettyDeviceIds;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment