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
dd88276d
Commit
dd88276d
authored
Jun 25, 2023
by
caotao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增数据透传开关
parent
fe5471c1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
26 deletions
+31
-26
MqttReceiveServiceImpl.java
...join/equipmanage/service/impl/MqttReceiveServiceImpl.java
+28
-24
application-dev.properties
...ystem-equip/src/main/resources/application-dev.properties
+3
-2
No files found.
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/service/impl/MqttReceiveServiceImpl.java
View file @
dd88276d
...
@@ -82,7 +82,8 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
...
@@ -82,7 +82,8 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
private
static
Map
<
String
,
TemperatureAlarmDto
>
temperatureMap
=
new
HashMap
<>();
private
static
Map
<
String
,
TemperatureAlarmDto
>
temperatureMap
=
new
HashMap
<>();
static
IEquipmentSpecificIndexService
equipmentSpecificIndexService
;
static
IEquipmentSpecificIndexService
equipmentSpecificIndexService
;
@Value
(
"${iot.async.flag}"
)
private
boolean
iotAsyncExecutorFlag
;
@Autowired
@Autowired
public
void
setEquipmentSpecificIndexService
(
IEquipmentSpecificIndexService
equipmentSpecificIndexService
)
{
public
void
setEquipmentSpecificIndexService
(
IEquipmentSpecificIndexService
equipmentSpecificIndexService
)
{
MqttReceiveServiceImpl
.
equipmentSpecificIndexService
=
equipmentSpecificIndexService
;
MqttReceiveServiceImpl
.
equipmentSpecificIndexService
=
equipmentSpecificIndexService
;
...
@@ -2548,29 +2549,32 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
...
@@ -2548,29 +2549,32 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
@PostConstruct
@PostConstruct
public
void
iotAsyncExecutor
()
{
public
void
iotAsyncExecutor
()
{
ThreadPoolTaskExecutor
workExecutor
=
new
ThreadPoolTaskExecutor
();
if
(
iotAsyncExecutorFlag
)
{
// 设置核心线程数
System
.
out
.
println
(
"-----------------iotAsyncExecutorFlagiotAsyncExecutorFlagiotAsyncExecutorFlagiotAsyncExecutorFlagiotAsyncExecutorFlagiotAsyncExecutorFlagiotAsyncExecutorFlag"
);
int
length
=
Runtime
.
getRuntime
().
availableProcessors
();
ThreadPoolTaskExecutor
workExecutor
=
new
ThreadPoolTaskExecutor
();
int
size
=
Math
.
max
(
length
,
80
);
// 设置核心线程数
workExecutor
.
setCorePoolSize
(
size
*
2
);
int
length
=
Runtime
.
getRuntime
().
availableProcessors
();
log
.
info
(
"装备服务初始化,系统线程数:{},运行线程数:{}"
,
length
,
size
);
int
size
=
Math
.
max
(
length
,
80
);
// 设置最大线程数
workExecutor
.
setCorePoolSize
(
size
*
2
);
workExecutor
.
setMaxPoolSize
(
workExecutor
.
getCorePoolSize
());
log
.
info
(
"装备服务初始化,系统线程数:{},运行线程数:{}"
,
length
,
size
);
//配置队列大小
// 设置最大线程数
workExecutor
.
setQueueCapacity
(
Integer
.
MAX_VALUE
);
workExecutor
.
setMaxPoolSize
(
workExecutor
.
getCorePoolSize
());
// 设置线程活跃时间(秒)
//配置队列大小
workExecutor
.
setKeepAliveSeconds
(
60
);
workExecutor
.
setQueueCapacity
(
Integer
.
MAX_VALUE
);
// 设置默认线程名称
// 设置线程活跃时间(秒)
workExecutor
.
setThreadNamePrefix
(
"装备服务-Iot透传消息消费线程池"
+
"-"
);
workExecutor
.
setKeepAliveSeconds
(
60
);
// 等待所有任务结束后再关闭线程池
// 设置默认线程名称
//当调度器shutdown被调用时,等待当前被调度的任务完成
workExecutor
.
setThreadNamePrefix
(
"装备服务-Iot透传消息消费线程池"
+
"-"
);
workExecutor
.
setWaitForTasksToCompleteOnShutdown
(
true
);
// 等待所有任务结束后再关闭线程池
//执行初始化
//当调度器shutdown被调用时,等待当前被调度的任务完成
workExecutor
.
initialize
();
workExecutor
.
setWaitForTasksToCompleteOnShutdown
(
true
);
// rejection-policy:当pool已经达到max size的时候,如何处理新任务
//执行初始化
// CALLER_RUNS:不在新线程中执行任务,而是有调用者所在的线程来执行
workExecutor
.
initialize
();
workExecutor
.
setRejectedExecutionHandler
(
new
ThreadPoolExecutor
.
CallerRunsPolicy
());
// rejection-policy:当pool已经达到max size的时候,如何处理新任务
this
.
dataExecutor
=
workExecutor
;
// CALLER_RUNS:不在新线程中执行任务,而是有调用者所在的线程来执行
workExecutor
.
setRejectedExecutionHandler
(
new
ThreadPoolExecutor
.
CallerRunsPolicy
());
this
.
dataExecutor
=
workExecutor
;
}
}
}
}
}
amos-boot-system-equip/src/main/resources/application-dev.properties
View file @
dd88276d
...
@@ -149,4 +149,5 @@ spring.influx.database=iot_platform
...
@@ -149,4 +149,5 @@ spring.influx.database=iot_platform
spring.influx.retention_policy
=
default
spring.influx.retention_policy
=
default
spring.influx.retention_policy_time
=
30d
spring.influx.retention_policy_time
=
30d
spring.influx.actions
=
10000
spring.influx.actions
=
10000
spring.influx.bufferLimit
=
20000
spring.influx.bufferLimit
=
20000
\ No newline at end of file
iot.async.flag
=
false
\ No newline at end of file
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