Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qg-push
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
head_group
qg-push
Commits
17854b39
Commit
17854b39
authored
Oct 31, 2022
by
李健华
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改redis配置
parent
41e4a7cd
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
21 additions
and
14 deletions
+21
-14
MsgPub.java
src/main/java/cn/quantgroup/config/MsgPub.java
+2
-1
MsgReceiver.java
src/main/java/cn/quantgroup/config/MsgReceiver.java
+2
-1
RedisConfig.java
src/main/java/cn/quantgroup/config/RedisConfig.java
+4
-2
WebsocketMessageHandler.java
...n/java/cn/quantgroup/handler/WebsocketMessageHandler.java
+9
-8
TcpServer.java
src/main/java/cn/quantgroup/server/TcpServer.java
+2
-1
RedisUtil.java
src/main/java/cn/quantgroup/utils/RedisUtil.java
+2
-1
No files found.
src/main/java/cn/quantgroup/config/MsgPub.java
View file @
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
);
...
...
src/main/java/cn/quantgroup/config/MsgReceiver.java
View file @
17854b39
...
...
@@ -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
;
...
...
src/main/java/cn/quantgroup/config/RedisConfig.java
View file @
17854b39
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
>
redis
Message
Template
(
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
));
...
...
src/main/java/cn/quantgroup/handler/WebsocketMessageHandler.java
View file @
17854b39
...
...
@@ -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 = "10
0";
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_4
0"
;
//
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
());
...
...
src/main/java/cn/quantgroup/server/TcpServer.java
View file @
17854b39
...
...
@@ -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
;
...
...
src/main/java/cn/quantgroup/utils/RedisUtil.java
View file @
17854b39
...
...
@@ -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
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment