Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yanxuan-wx-store-sharer
Overview
Overview
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
wx
yanxuan-wx-store-sharer
Commits
c93fb097
Commit
c93fb097
authored
Mar 14, 2025
by
fanjiaxin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
联调问题处理
parent
edc17019
Pipeline
#71619
passed with stages
in 56 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
58 additions
and
1 deletions
+58
-1
Application.java
...netease/yanxuan/wx/store/sharer/assembly/Application.java
+2
-0
ExecutorConfig.java
...se/yanxuan/wx/store/sharer/biz/config/ExecutorConfig.java
+53
-0
ProductServiceImpl.java
.../wx/store/sharer/biz/service/impl/ProductServiceImpl.java
+3
-1
No files found.
yanxuan-wx-store-sharer-assembly/src/main/java/com/netease/yanxuan/wx/store/sharer/assembly/Application.java
View file @
c93fb097
...
...
@@ -7,10 +7,12 @@ import org.springframework.boot.SpringApplication;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.web.servlet.support.SpringBootServletInitializer
;
import
org.springframework.context.annotation.ComponentScan
;
import
org.springframework.scheduling.annotation.EnableAsync
;
/**
* 项目启动类
*/
@EnableAsync
@ComponentScan
(
basePackages
=
"com.netease.yanxuan.wx.store.sharer"
)
@EnableApolloConfig
@EnableMissaClients
(
basePackages
=
"com.netease.yanxuan.wx.store.sharer"
)
...
...
yanxuan-wx-store-sharer-biz/src/main/java/com/netease/yanxuan/wx/store/sharer/biz/config/ExecutorConfig.java
0 → 100644
View file @
c93fb097
package
com
.
netease
.
yanxuan
.
wx
.
store
.
sharer
.
biz
.
config
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.scheduling.annotation.EnableAsync
;
import
org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor
;
import
java.util.concurrent.Executor
;
import
java.util.concurrent.ThreadPoolExecutor
;
/**
* 线程池配置类
*
* @author fanjiaxin
* @date 2024/6/12 15:55
*/
@Slf4j
@Configuration
@EnableAsync
public
class
ExecutorConfig
{
/**
* 异步线程池
*/
@Bean
(
name
=
"asyncProductListServiceExecutor"
)
public
Executor
asyncProductListServiceExecutor
()
{
log
.
info
(
"start asyncProductListServiceExecutor..."
);
ThreadPoolTaskExecutor
executor
=
new
ThreadPoolTaskExecutor
();
//配置核心线程数
executor
.
setCorePoolSize
(
10
);
//配置最大线程数
executor
.
setMaxPoolSize
(
20
);
//配置队列大小
executor
.
setQueueCapacity
(
500
);
//线程空闲时间
executor
.
setKeepAliveSeconds
(
30
);
//配置线程池中的线程的名称前缀
executor
.
setThreadNamePrefix
(
"async-product-list-service-executor-"
);
/**
* rejection-policy:当pool已经达到max size的时候,如何处理新任务
* CALLER_RUNS:不在新线程中执行任务,而是有调用者所在的线程来执行
*/
executor
.
setRejectedExecutionHandler
(
new
ThreadPoolExecutor
.
CallerRunsPolicy
());
//等待所有任务完成再关闭
executor
.
setWaitForTasksToCompleteOnShutdown
(
true
);
//最长等待时间,秒
executor
.
setAwaitTerminationSeconds
(
60
);
//初始化执行器
executor
.
initialize
();
return
executor
;
}
}
yanxuan-wx-store-sharer-biz/src/main/java/com/netease/yanxuan/wx/store/sharer/biz/service/impl/ProductServiceImpl.java
View file @
c93fb097
...
...
@@ -29,6 +29,7 @@ import java.util.List;
import
java.util.Objects
;
import
java.util.Optional
;
import
java.util.stream.Collectors
;
import
java.util.concurrent.Executor
;
/**
* @Description 商品-业务实现类
...
...
@@ -44,6 +45,7 @@ public class ProductServiceImpl implements IProductService {
private
final
WeChatShopPromoteProductLinkRequest
weChatShopPromoteProductLinkRequest
;
private
final
WeChatShopSharerListRequest
weChatShopSharerListRequest
;
private
final
DrmSharerConfig
drmSharerConfig
;
private
final
Executor
asyncProductListServiceExecutor
;
@Override
...
...
@@ -120,7 +122,7 @@ public class ProductServiceImpl implements IProductService {
listVO
.
setProductId
(
item
.
getProduct_id
());
listVO
.
setProductPromotionLink
(
productInfo
.
getProduct_promotion_link
());
return
listVO
;
});
}
,
asyncProductListServiceExecutor
);
// 过滤空
productList
=
Optional
.
of
(
productList
).
orElseGet
(
ArrayList:
:
new
)
.
stream
()
...
...
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