Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-boot-biz
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
项目统一框架
amos-boot-biz
Commits
60dd03cb
Commit
60dd03cb
authored
Feb 03, 2023
by
tangwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
测试
parent
749ff636
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
3 deletions
+12
-3
EquipmentIotMqttReceiveConfig.java
...oin/equipmanage/config/EquipmentIotMqttReceiveConfig.java
+12
-3
No files found.
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/config/EquipmentIotMqttReceiveConfig.java
View file @
60dd03cb
...
...
@@ -166,7 +166,7 @@ public class EquipmentIotMqttReceiveConfig {
//mqttReceiveService.handlerMqttIncrementMessage(topic, msg);
//异步处理
EquipmentIotMqttReceiveConfig
controllerProxy
=
SpringUtils
.
getBean
(
EquipmentIotMqttReceiveConfig
.
class
);
controllerProxy
.
handlerMqttIncrementMessage
(
topic
,
msg
);
controllerProxy
.
namePrefix
handlerMqttIncrementMessage
(
topic
,
msg
);
}
else
if
(
dataType
.
equals
(
"event"
)
&&
StringUtil
.
isNotEmpty
(
msg
))
{
...
...
@@ -184,7 +184,7 @@ public class EquipmentIotMqttReceiveConfig {
@Async
(
"equipAsyncExecutor"
)
public
void
handlerMqttIncrementMessage
(
String
topic
,
String
msg
)
{
public
void
namePrefix
handlerMqttIncrementMessage
(
String
topic
,
String
msg
)
{
if
(
cluster
.
equals
(
"cluster"
)){
//不同设备加锁,防止消息顺序错乱,此处加锁高并发下小概率会出现顺序错乱,
...
...
@@ -192,9 +192,18 @@ public class EquipmentIotMqttReceiveConfig {
RLock
lock
=
redisson
.
getLock
(
topic
);
try
{
//拿锁失败10停止尝试,20秒后直接释放锁 无论是返回 true 还是 false,都会继续执行之后的代码。
lock
.
tryLock
(
10
,
20
,
TimeUnit
.
SECONDS
);
boolean
flag
=
lock
.
tryLock
(
2
,
20
,
TimeUnit
.
SECONDS
);
System
.
out
.
println
(
"msg==================================="
+
flag
);
for
(
int
i
=
0
;
i
<=
1000000
;
i
++)
{
System
.
out
.
println
(
"msg==================================="
+
i
);
}
//为了防止重复
mqttReceiveService
.
handlerMqttIncrementMessage
(
topic
,
msg
);
System
.
out
.
println
(
"msg==================================="
+
msg
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
...
...
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