Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
eshiled-new
/
ne-shield-kafkaconsumer-gpsbs
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit fdc1424a
authored
Jan 04, 2022
by
杨林龙
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
优化Gps基站消费逻辑
1 parent
793d5904
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
src/main/java/cn/com/glsx/kafka/service/TransitHandleService.java
src/main/java/cn/com/glsx/kafka/service/TransitHandleService.java
View file @
fdc1424
...
...
@@ -122,14 +122,14 @@ public class TransitHandleService {
List
<
String
>
snTempList
=
Lists
.
newArrayList
();
log
.
info
(
"开始插入或者更新Gps和基站的数据大小==="
+
snSet
.
size
());
snSet
.
forEach
(
sn
->
{
Object
obj
=
redisUtils
.
get
(
setKey
(
sn
));
if
(
"1"
.
equals
(
obj
)
)
{
Integer
lockValue
=
(
Integer
)
redisUtils
.
get
(
setKey
(
sn
));
if
(
null
!=
lockValue
&&
1
==
lockValue
)
{
log
.
info
(
"设备号:"
+
sn
+
"已经在redis中加锁,在此服务器中不消费"
);
return
;
}
snTempList
.
add
(
sn
);
//消费的设备号进行加锁 保证只在一台机器上处理入库操作
redisUtils
.
setnx
(
setKey
(
sn
),
"1"
,
60
);
redisUtils
.
setnx
(
setKey
(
sn
),
1
,
60
);
});
// 清空缓存set
snSet
.
clear
();
...
...
@@ -167,7 +167,7 @@ public class TransitHandleService {
// 将sn解锁
snTempList
.
forEach
(
sn
->
{
//对于已经入库的设备进行解锁
redisUtils
.
unlock
(
setKey
(
sn
),
"0"
);
redisUtils
.
unlock
(
setKey
(
sn
),
0
);
});
log
.
info
(
"入库结束,已经同步解锁redis的锁"
);
// 临时时间设置为此次插入数据库的时间
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment