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
98a7ca1e
Commit
98a7ca1e
authored
Feb 03, 2023
by
tangwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改bug
parent
60dd03cb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
17 deletions
+12
-17
EquipmentIotMqttReceiveConfig.java
...oin/equipmanage/config/EquipmentIotMqttReceiveConfig.java
+12
-17
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 @
98a7ca1e
...
@@ -156,7 +156,8 @@ public class EquipmentIotMqttReceiveConfig {
...
@@ -156,7 +156,8 @@ public class EquipmentIotMqttReceiveConfig {
return
message
->
{
return
message
->
{
String
topic
=
message
.
getHeaders
().
get
(
"mqtt_receivedTopic"
).
toString
();
String
topic
=
message
.
getHeaders
().
get
(
"mqtt_receivedTopic"
).
toString
();
//异步处理
EquipmentIotMqttReceiveConfig
controllerProxy
=
SpringUtils
.
getBean
(
EquipmentIotMqttReceiveConfig
.
class
);
String
msg
=
message
.
getPayload
().
toString
();
String
msg
=
message
.
getPayload
().
toString
();
int
endIndex
=
topic
.
lastIndexOf
(
"/"
);
int
endIndex
=
topic
.
lastIndexOf
(
"/"
);
if
(
endIndex
>
0
&&
StringUtil
.
isNotEmpty
(
message
))
{
if
(
endIndex
>
0
&&
StringUtil
.
isNotEmpty
(
message
))
{
...
@@ -164,14 +165,13 @@ public class EquipmentIotMqttReceiveConfig {
...
@@ -164,14 +165,13 @@ public class EquipmentIotMqttReceiveConfig {
if
(
dataType
.
equals
(
"property"
)
&&
StringUtil
.
isNotEmpty
(
msg
))
{
if
(
dataType
.
equals
(
"property"
)
&&
StringUtil
.
isNotEmpty
(
msg
))
{
//mqttReceiveService.handlerMqttIncrementMessage(topic, msg);
//mqttReceiveService.handlerMqttIncrementMessage(topic, msg);
//异步处理
EquipmentIotMqttReceiveConfig
controllerProxy
=
SpringUtils
.
getBean
(
EquipmentIotMqttReceiveConfig
.
class
);
controllerProxy
.
namePrefixhandlerMqttIncrementMessage
(
topic
,
msg
);
controllerProxy
.
namePrefixhandlerMqttIncrementMessage
(
topic
,
msg
);
}
else
if
(
dataType
.
equals
(
"event"
)
&&
StringUtil
.
isNotEmpty
(
msg
))
{
}
else
if
(
dataType
.
equals
(
"event"
)
&&
StringUtil
.
isNotEmpty
(
msg
))
{
mqttEventReceiveService
.
handlerMqttIncrementMessage
(
topic
,
msg
);
//
mqttEventReceiveService.handlerMqttIncrementMessage(topic, msg);
controllerProxy
.
namePrefixhandlerMqttIncrementMessageEven
(
topic
,
msg
);
}
}
}
}
};
};
...
@@ -181,7 +181,10 @@ public class EquipmentIotMqttReceiveConfig {
...
@@ -181,7 +181,10 @@ public class EquipmentIotMqttReceiveConfig {
this
.
mqttReceiveService
=
mqttReceiveService
;
this
.
mqttReceiveService
=
mqttReceiveService
;
}
}
@Async
(
"equipAsyncExecutor"
)
public
void
namePrefixhandlerMqttIncrementMessageEven
(
String
topic
,
String
msg
)
{
mqttEventReceiveService
.
handlerMqttIncrementMessage
(
topic
,
msg
);
}
@Async
(
"equipAsyncExecutor"
)
@Async
(
"equipAsyncExecutor"
)
public
void
namePrefixhandlerMqttIncrementMessage
(
String
topic
,
String
msg
)
{
public
void
namePrefixhandlerMqttIncrementMessage
(
String
topic
,
String
msg
)
{
...
@@ -192,18 +195,10 @@ public class EquipmentIotMqttReceiveConfig {
...
@@ -192,18 +195,10 @@ public class EquipmentIotMqttReceiveConfig {
RLock
lock
=
redisson
.
getLock
(
topic
);
RLock
lock
=
redisson
.
getLock
(
topic
);
try
{
try
{
//拿锁失败10停止尝试,20秒后直接释放锁 无论是返回 true 还是 false,都会继续执行之后的代码。
//拿锁失败10停止尝试,20秒后直接释放锁 无论是返回 true 还是 false,都会继续执行之后的代码。
boolean
flag
=
lock
.
tryLock
(
2
,
20
,
TimeUnit
.
SECONDS
);
boolean
flag
=
lock
.
tryLock
(
10
,
20
,
TimeUnit
.
SECONDS
);
System
.
out
.
println
(
"msg==================================="
+
flag
);
for
(
int
i
=
0
;
i
<=
1000000
;
i
++)
{
System
.
out
.
println
(
"msg==================================="
+
i
);
}
//为了防止重复
mqttReceiveService
.
handlerMqttIncrementMessage
(
topic
,
msg
);
mqttReceiveService
.
handlerMqttIncrementMessage
(
topic
,
msg
);
System
.
out
.
println
(
"msg==================================="
+
msg
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
finally
{
}
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