Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
discovery
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
谢捷峰
discovery
Commits
b451b5a6
Commit
b451b5a6
authored
Jun 30, 2018
by
Nepxion
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加注册失败后事件发布/订阅功能
parent
93beba08
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
2 deletions
+7
-2
discovery-plugin-framework/src/main/java/com/nepxion/discovery/plugin/framework/constant/PluginConstant.java
+1
-0
discovery-plugin-framework/src/main/java/com/nepxion/discovery/plugin/framework/listener/impl/IpAddressFilterRegisterListener.java
+4
-0
discovery-springcloud-example/src/main/resources/bootstrap.properties
+2
-2
No files found.
discovery-plugin-framework/src/main/java/com/nepxion/discovery/plugin/framework/constant/PluginConstant.java
View file @
b451b5a6
...
...
@@ -11,6 +11,7 @@ package com.nepxion.discovery.plugin.framework.constant;
public
class
PluginConstant
{
public
static
final
String
SPRING_APPLICATION_REGISTER_CONTROL_ENABLED
=
"spring.application.register.control.enabled"
;
public
static
final
String
SPRING_APPLICATION_REGISTER_FAILURE_EVENT_ENABLED
=
"spring.application.register.failure.event.enabled"
;
public
static
final
String
SPRING_APPLICATION_DISCOVERY_CONTROL_ENABLED
=
"spring.application.discovery.control.enabled"
;
public
static
final
String
SPRING_APPLICATION_DISCOVERY_REMOTE_CONFIG_ENABLED
=
"spring.application.discovery.remote.config.enabled"
;
...
...
discovery-plugin-framework/src/main/java/com/nepxion/discovery/plugin/framework/listener/impl/IpAddressFilterRegisterListener.java
View file @
b451b5a6
...
...
@@ -20,6 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.cloud.client.serviceregistry.Registration
;
import
com.nepxion.discovery.plugin.framework.adapter.PluginAdapter
;
import
com.nepxion.discovery.plugin.framework.constant.PluginConstant
;
import
com.nepxion.discovery.plugin.framework.entity.FilterEntity
;
import
com.nepxion.discovery.plugin.framework.entity.FilterType
;
import
com.nepxion.discovery.plugin.framework.entity.RegisterEntity
;
...
...
@@ -113,7 +114,10 @@ public class IpAddressFilterRegisterListener extends AbstractRegisterListener {
}
private
void
onRegisterFaiure
(
FilterType
filterType
,
String
serviceId
,
String
ipAddress
,
int
port
)
{
Boolean
registerFailureEventEnabled
=
environment
.
getProperty
(
PluginConstant
.
SPRING_APPLICATION_REGISTER_FAILURE_EVENT_ENABLED
,
Boolean
.
class
,
Boolean
.
FALSE
);
if
(
registerFailureEventEnabled
)
{
pluginPublisher
.
asyncPublish
(
new
RegisterFaiureEvent
(
filterType
,
serviceId
,
ipAddress
,
port
));
}
throw
new
PluginException
(
ipAddress
+
" isn't allowed to register to Discovery server, because it is in blacklist"
);
}
...
...
discovery-springcloud-example/src/main/resources/bootstrap.properties
View file @
b451b5a6
...
...
@@ -19,8 +19,8 @@ management.health.consul.enabled=false
# Plugin config
# 开启和关闭服务注册层面的控制。一旦关闭,服务注册的黑/白名单过滤功能将失效。缺失则默认为true
spring.application.register.control.enabled
=
true
# 开启和关闭禁止注册后发送异步事件通知。一旦关闭,禁止注册后,不会发送异步事件通知。缺失则默认为
tru
e
spring.application.register.failure.event.enabled
=
tru
e
# 开启和关闭禁止注册后发送异步事件通知。一旦关闭,禁止注册后,不会发送异步事件通知。缺失则默认为
fals
e
spring.application.register.failure.event.enabled
=
fals
e
# 开启和关闭服务发现层面的控制。一旦关闭,服务多版本调用的控制功能将失效,动态屏蔽指定IP地址的服务实例被发现的功能将失效。缺失则默认为true
spring.application.discovery.control.enabled
=
true
...
...
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