Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
commons
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DevOps
commons
Commits
8bf7320a
Commit
8bf7320a
authored
Feb 08, 2018
by
ag
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 修复一个严重错误. 会导致项目无法启动的问题.
parent
f6ed221d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
8 deletions
+4
-8
BaseDestroyHandler.java
.../java/cn/quantgroup/tech/shutdown/BaseDestroyHandler.java
+4
-8
No files found.
commons-spring/src/main/java/cn/quantgroup/tech/shutdown/BaseDestroyHandler.java
View file @
8bf7320a
...
...
@@ -2,14 +2,11 @@ package cn.quantgroup.tech.shutdown;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.amqp.rabbit.config.RabbitListenerConfigUtils
;
import
org.springframework.amqp.rabbit.core.RabbitTemplate
;
import
org.springframework.amqp.rabbit.listener.RabbitListenerEndpointRegistry
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnBean
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.Lifecycle
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.stereotype.Component
;
import
org.springframework.context.annotation.Configuration
;
import
javax.annotation.PreDestroy
;
...
...
@@ -19,20 +16,18 @@ import javax.annotation.PreDestroy;
* @author ag
*/
@Slf4j
@Co
mponent
@Co
nfiguration
public
class
BaseDestroyHandler
{
@Autowired
private
ApplicationContext
applicationContext
;
@PreDestroy
@ConditionalOnBean
(
RedisTemplate
.
class
)
private
void
stopRedisSub
()
{
log
.
info
(
"我什么都没做, redis stopped"
);
}
@PreDestroy
@ConditionalOnBean
(
RabbitTemplate
.
class
)
private
void
stopRabbitMQ
()
{
try
{
RabbitListenerEndpointRegistry
rabbitListenerEndpointRegistry
=
applicationContext
.
getBean
(
...
...
@@ -40,7 +35,8 @@ public class BaseDestroyHandler {
RabbitListenerEndpointRegistry
.
class
);
rabbitListenerEndpointRegistry
.
getListenerContainers
().
forEach
(
Lifecycle:
:
stop
);
}
catch
(
Exception
e
)
{
log
.
error
(
"貌似停止 MQ 遇到了问题..."
);
//貌似这段日志不会打印...
log
.
error
(
"貌似停止 MQ 遇到了问题... 你有MQ么? "
);
}
log
.
info
(
"MQ listener stopped"
);
}
...
...
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