记得上下班打卡 | git大法好,push需谨慎
Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
liquidnet-bus-v1
Project
Project
Details
Activity
Releases
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
董敬伟
liquidnet-bus-v1
Commits
75b8d4f3
Commit
75b8d4f3
authored
May 08, 2021
by
张国柄
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
配置zuul;
parent
7e633f3f
Changes
29
Hide whitespace changes
Inline
Side-by-side
Showing
29 changed files
with
296 additions
and
434 deletions
+296
-434
application-common-service.yml
...us-config/liquidnet-config/application-common-service.yml
+1
-1
application-prod.yml
liquidnet-bus-config/liquidnet-config/application-prod.yml
+1
-1
liquidnet-service-adam-dev.yml
...us-config/liquidnet-config/liquidnet-service-adam-dev.yml
+2
-1
liquidnet-service-adam.yml
...et-bus-config/liquidnet-config/liquidnet-service-adam.yml
+3
-2
liquidnet-service-kylin-dev.yml
...s-config/liquidnet-config/liquidnet-service-kylin-dev.yml
+1
-1
liquidnet-service-kylin.yml
...t-bus-config/liquidnet-config/liquidnet-service-kylin.yml
+1
-1
liquidnet-support-zuul-dev.yml
...us-config/liquidnet-config/liquidnet-support-zuul-dev.yml
+8
-0
liquidnet-support-zuul-prod.yml
...s-config/liquidnet-config/liquidnet-support-zuul-prod.yml
+8
-0
liquidnet-support-zuul-test.yml
...s-config/liquidnet-config/liquidnet-support-zuul-test.yml
+9
-0
liquidnet-support-zuul.yml
...et-bus-config/liquidnet-config/liquidnet-support-zuul.yml
+79
-52
pom.xml
liquidnet-bus-support/liquidnet-support-zuul/pom.xml
+9
-0
SupportZuulApplication.java
...va/com/liquidnet/support/zuul/SupportZuulApplication.java
+34
-3
ZuulDocumentationConfig.java
.../support/zuul/config/swagger/ZuulDocumentationConfig.java
+45
-0
ZuulSwagger2Config.java
...idnet/support/zuul/config/swagger/ZuulSwagger2Config.java
+26
-0
ErrorExtFilter.java
...m/liquidnet/support/zuul/filter/error/ErrorExtFilter.java
+0
-38
ErrorFilter.java
.../com/liquidnet/support/zuul/filter/error/ErrorFilter.java
+0
-45
ThrowExceptionPostFilter.java
...et/support/zuul/filter/post/ThrowExceptionPostFilter.java
+0
-39
ThrowExceptionFilter.java
...quidnet/support/zuul/filter/pre/ThrowExceptionFilter.java
+0
-48
application-test.yml
...dnet-support-zuul/src/main/resources/application-test.yml
+0
-8
application-zuul.yml
...dnet-support-zuul/src/main/resources/application-zuul.yml
+0
-67
application.yml
...liquidnet-support-zuul/src/main/resources/application.yml
+0
-3
banner.txt
...port/liquidnet-support-zuul/src/main/resources/banner.txt
+0
-14
bootstrap-dev.yml
...quidnet-support-zuul/src/main/resources/bootstrap-dev.yml
+14
-0
bootstrap-prod.yml
...uidnet-support-zuul/src/main/resources/bootstrap-prod.yml
+14
-18
bootstrap-support-zuul.yml
...upport-zuul/src/main/resources/bootstrap-support-zuul.yml
+17
-0
bootstrap-test.yml
...uidnet-support-zuul/src/main/resources/bootstrap-test.yml
+14
-18
bootstrap.yml
...t/liquidnet-support-zuul/src/main/resources/bootstrap.yml
+5
-14
logback.xml
...ort/liquidnet-support-zuul/src/main/resources/logback.xml
+0
-60
pom.xml
liquidnet-bus-support/pom.xml
+5
-0
No files found.
liquidnet-bus-config/liquidnet-config/application-common-service.yml
View file @
75b8d4f3
...
@@ -17,6 +17,6 @@ management:
...
@@ -17,6 +17,6 @@ management:
rabbitmq
:
rabbitmq
:
enabled
:
false
enabled
:
false
security
:
security
:
enabled
:
false
enabled
:
false
#common-service-end
#common-service-end
liquidnet-bus-config/liquidnet-config/application-prod.yml
View file @
75b8d4f3
...
@@ -15,7 +15,7 @@ liquidnet:
...
@@ -15,7 +15,7 @@ liquidnet:
username
:
liquidnet
username
:
liquidnet
password
:
LiquidNet!@#4
password
:
LiquidNet!@#4
knife4j
:
knife4j
:
disable
:
fals
e
disable
:
tru
e
redis
:
redis
:
host
:
192.168.31.205
host
:
192.168.31.205
port
:
6379
port
:
6379
...
...
liquidnet-bus-config/liquidnet-config/liquidnet-service-adam-dev.yml
View file @
75b8d4f3
...
@@ -79,9 +79,10 @@ spring:
...
@@ -79,9 +79,10 @@ spring:
transportMode
:
"
NIO"
transportMode
:
"
NIO"
data
:
data
:
mongodb
:
mongodb
:
uri
:
mongodb://${liquidnet.mongodb.host}:${liquidnet.mongodb.port}/ln_adam_mdb
#
uri: mongodb://${liquidnet.mongodb.host}:${liquidnet.mongodb.port}/ln_adam_mdb
#本地测试证书
#本地测试证书
sslEnabled
:
false
sslEnabled
:
false
database
:
ln_adam_mdb
trustStore
:
trustStore
:
trustStorePassword
:
trustStorePassword
:
# uri: mongodb://smartnet:a43ljKmK8oqdOO902P@smartnet-nonprod-docdb-docdb.cluster-cgjsqu7tuka2.ap-southeast-1.docdb.amazonaws.com:27017/liquidnet_mgdb?ssl=true&ssl_ca_certs=/Users/anjiabin/Downloads/rds-combined-ca-bundle.pem&replicaSet=rs0&readPreference=secondaryPreferred&retryWrites=false
# uri: mongodb://smartnet:a43ljKmK8oqdOO902P@smartnet-nonprod-docdb-docdb.cluster-cgjsqu7tuka2.ap-southeast-1.docdb.amazonaws.com:27017/liquidnet_mgdb?ssl=true&ssl_ca_certs=/Users/anjiabin/Downloads/rds-combined-ca-bundle.pem&replicaSet=rs0&readPreference=secondaryPreferred&retryWrites=false
liquidnet-bus-config/liquidnet-config/liquidnet-service-adam.yml
View file @
75b8d4f3
...
@@ -8,7 +8,7 @@ server:
...
@@ -8,7 +8,7 @@ server:
knife4j
:
knife4j
:
production
:
${liquidnet.knife4j.disable}
production
:
${liquidnet.knife4j.disable}
basic
:
basic
:
enable
:
tru
e
enable
:
fals
e
username
:
${liquidnet.security.username}
username
:
${liquidnet.security.username}
password
:
${liquidnet.security.password}
password
:
${liquidnet.security.password}
# -----------------------------------------------------------
# -----------------------------------------------------------
...
@@ -70,8 +70,9 @@ spring:
...
@@ -70,8 +70,9 @@ spring:
password
:
${liquidnet.rabbitmq.password}
password
:
${liquidnet.rabbitmq.password}
data
:
data
:
mongodb
:
mongodb
:
uri
:
mongodb://${liquidnet.mongodb.
host}:${liquidnet.mongodb.port}/${liquidnet.mongodb.gfsdatabasename}
uri
:
mongodb://${liquidnet.mongodb.
user}:${liquidnet.mongodb.pwd}@${liquidnet.mongodb.host}:${liquidnet.mongodb.port}/?authSource=admin
sslEnabled
:
false
sslEnabled
:
false
database
:
${spring.data.mongodb.database}
datasource
:
datasource
:
name
:
${liquidnet.mysql.database-name}
name
:
${liquidnet.mysql.database-name}
url
:
jdbc:mysql://${liquidnet.mysql.urlHostAndPort}/${liquidnet.mysql.database-name}?serverTimezone=UTC&characterEncoding=utf-8&useSSL=false
url
:
jdbc:mysql://${liquidnet.mysql.urlHostAndPort}/${liquidnet.mysql.database-name}?serverTimezone=UTC&characterEncoding=utf-8&useSSL=false
...
...
liquidnet-bus-config/liquidnet-config/liquidnet-service-kylin-dev.yml
View file @
75b8d4f3
...
@@ -3,7 +3,7 @@ liquidnet:
...
@@ -3,7 +3,7 @@ liquidnet:
updating
:
updating
:
switch
:
false
switch
:
false
info
:
info
:
port
:
900
1
port
:
900
2
context
:
context
:
# context: /service-kylin
# context: /service-kylin
name
:
liquidnet-service-kylin
name
:
liquidnet-service-kylin
...
...
liquidnet-bus-config/liquidnet-config/liquidnet-service-kylin.yml
View file @
75b8d4f3
...
@@ -8,7 +8,7 @@ server:
...
@@ -8,7 +8,7 @@ server:
knife4j
:
knife4j
:
production
:
${liquidnet.knife4j.disable}
production
:
${liquidnet.knife4j.disable}
basic
:
basic
:
enable
:
tru
e
enable
:
fals
e
username
:
${liquidnet.security.username}
username
:
${liquidnet.security.username}
password
:
${liquidnet.security.password}
password
:
${liquidnet.security.password}
# -----------------------------------------------------------
# -----------------------------------------------------------
...
...
liquidnet-bus-config/liquidnet-config/liquidnet-support-zuul-dev.yml
0 → 100755
View file @
75b8d4f3
liquidnet
:
info
:
port
:
7003
# context: /support-zuul
name
:
liquidnet-support-zuul
logfile
:
path
:
./logs
name
:
support-zuul
liquidnet-bus-config/liquidnet-config/liquidnet-support-zuul-prod.yml
0 → 100755
View file @
75b8d4f3
liquidnet
:
info
:
port
:
7003
# context: /support-zuul
name
:
liquidnet-support-zuul
logfile
:
path
:
./logs
name
:
support-zuul
\ No newline at end of file
liquidnet-bus-config/liquidnet-config/liquidnet-support-zuul-test.yml
0 → 100755
View file @
75b8d4f3
liquidnet
:
info
:
port
:
7003
# context: /support-zuul
name
:
liquidnet-support-zuul
logfile
:
path
:
./logs
name
:
support-zuul
liquidnet-bus-config/liquidnet-config/liquidnet-support-zuul.yml
View file @
75b8d4f3
server
:
port
:
${liquidnet.info.port}
tomcat
:
uri-encoding
:
UTF-8
servlet
:
context-path
:
# context-path: ${liquidnet.info.context}
# server:
# tomcat:
# accept-count: 500
# max-threads: 500
# min-spare-threads: 100
# max-connections: 1000
# connection-timeout: 5000
# -----------------------------------------------------------
knife4j
:
production
:
${liquidnet.knife4j.disable}
basic
:
enable
:
true
username
:
${liquidnet.security.username}
password
:
${liquidnet.security.password}
# -----------------------------------------------------------
logging
:
file
:
name
:
${liquidnet.logfile.path}/${liquidnet.logfile.name}.log
max-size
:
200MB
pattern
:
file
:
'
%d{yyyy-MM-dd
HH:mm:ss.SSS}
[
%-5level]
%thread
[%logger{96}:%line]
-
%msg%n'
console
:
'
%d{yyyy-MM-dd
HH:mm:ss.SSS}
[
%-5level]
%thread
[%logger{96}:%line]
-
%msg%n'
rolling-file-name
:
${liquidnet.logfile.path}/${liquidnet.logfile.name}-%d{yyyy-MM-dd}.%i.log
level
:
root
:
info
#以下是为指定包设置日志级别
com.netflix
:
info
# -----------------------------------------------------------
spring
:
spring
:
application
:
application
:
name
:
liquidnet-gateway-zuul
name
:
${liquidnet.info.name}
server
:
autoconfigure
:
port
:
8040
exclude
:
org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
server
:
profiles
:
tomcat
:
include
:
common-service
accept-count
:
500
# cloud:
max-threads
:
500
# bus:
min-spare-threads
:
100
# destination: springCloudBus.${liquidnet.info.name}.port${liquidnet.info.port}
max-connections
:
1000
# trace:
connection-timeout
:
5000
# enabled: true
# -----------------------------------------------------------
eureka
:
eureka
:
client
:
# client:
healthcheck
:
# register-with-eureka: true
enabled
:
true
# fetch-registry: true
serviceUrl
:
# serviceUrl:
defaultZone
:
${liquidnet.eureka.serviceUrl}
# defaultZone: http://${liquidnet.security.username}:${liquidnet.security.password}@${liquidnet.eureka.host}/eureka-server/eureka
instance
:
instance
:
prefer-ip-address
:
true
hostname
:
${spring.cloud.client.ip-address}
instance-id
:
${spring.application.name}:${spring.cloud.client.ipAddress}:${spring.application.instance_id:${server.port}}
lease-expiration-duration-in-seconds
:
15
#服务过期时间配置,超过这个时间没有接收到心跳EurekaServer就会将这个实例剔除
lease-renewal-interval-in-seconds
:
15
lease-renewal-interval-in-seconds
:
5
#服务刷新时间配置,每隔这个时间会主动心跳一次
lease-expiration-duration-in-seconds
:
30
prefer-ip-address
:
true
metadata-map
:
instance-id
:
${spring.application.name}:${spring.cloud.client.ip-address}:${spring.application.instance_id:${server.port}}
zone
:
YGZX
# eureka可以理解的元数据
# -----------------------------------------------------------
liquidnet
:
YGZX
# 不会影响客户端行为
server
:
eviction-interval-timer-in-ms
:
30000
hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds
:
60000
ribbon
:
ConnectTimeout
:
3000
ReadTimeout
:
60000
eureka
:
enabled
:
true
zuul
:
zuul
:
prefix
:
/
host
:
host
:
max-per-route-connections
:
1000
max-per-route-connections
:
1000
max-total-connections
:
2000
max-total-connections
:
2000
routes
:
routes
:
liquidnet-provider-sms
:
/sms/**
liquidnet-service-adam
:
/adam/**
liquidnet-provider-sequence
:
/sequence/**
liquidnet-service-kylin
:
/kylin/**
liquidnet-provider-data
:
/data/**
# 忽略的服务,有些后端服务是不需要让网管代理的,防止服务侵入
liquidnet-provider-user
:
/user/**
ignored-services
:
"
*"
liquidnet-provider-p2m
:
/p2m/**
# 忽略的接口,屏蔽接口
liquidnet-provider-activity
:
/activity/**
# ignored-patterns: /**/div/**
pay-third-charge
:
/pay_charge/**
# 以下为禁用某个过滤器
liquidnet-pay-query
:
/pay_query/**
# XXXFilter: # 类的名字
liquidnet-client-app
:
/app_api/**
# pre: # 类型
# disable: true
zuul.ThrowExceptionPostFilter.post.disable
:
true
logging
:
#解决错误 com.netflix.client.ClientException: Load balancer does not have available server for client:panfeng-item-service
level
:
#这样就可以即指定path与URL,又不破坏Zuul的Hystrix与Ribbon特性了。
com.netflix
:
debug
#开启eureka负载均衡策略
ribbon
:
#zuul:
eureka
:
# prefix: /api
enabled
:
true
# 为Ribbon禁用Eureka
# strip-prefix: false
#liquidnet-service-sequence:
# ribbon:
# listOfServers: 192.168.137.1:9001
# -----------------------------------------------------------
liquidnet-bus-support/liquidnet-support-zuul/pom.xml
View file @
75b8d4f3
...
@@ -28,5 +28,14 @@
...
@@ -28,5 +28,14 @@
<groupId>
org.springframework.cloud
</groupId>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-config
</artifactId>
<artifactId>
spring-cloud-starter-config
</artifactId>
</dependency>
</dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-openfeign
</artifactId>
</dependency>
<dependency>
<groupId>
com.liquidnet
</groupId>
<artifactId>
liquidnet-common-service-base
</artifactId>
<version>
1.0-SNAPSHOT
</version>
</dependency>
</dependencies>
</dependencies>
</project>
</project>
liquidnet-bus-support/liquidnet-support-zuul/src/main/java/com/liquidnet/support/zuul/SupportZuulApplication.java
View file @
75b8d4f3
package
com
.
liquidnet
.
support
.
zuul
;
package
com
.
liquidnet
.
support
.
zuul
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.CommandLineRunner
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.cloud.client.discovery.EnableDiscoveryClient
;
import
org.springframework.cloud.client.discovery.EnableDiscoveryClient
;
import
org.springframework.cloud.netflix.zuul.EnableZuulProxy
;
import
org.springframework.cloud.netflix.zuul.EnableZuulProxy
;
import
org.springframework.cloud.openfeign.EnableFeignClients
;
import
org.springframework.core.env.Environment
;
import
java.net.InetAddress
;
import
java.net.UnknownHostException
;
import
java.util.Arrays
;
@EnableDiscoveryClient
@Slf4j
@EnableFeignClients
@EnableZuulProxy
@EnableZuulProxy
@SpringBootApplication
@SpringBootApplication
(
scanBasePackages
=
{
"com.liquidnet"
})
public
class
SupportZuulApplication
{
public
class
SupportZuulApplication
implements
CommandLineRunner
{
@Autowired
private
Environment
environment
;
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
SupportZuulApplication
.
class
,
args
);
SpringApplication
.
run
(
SupportZuulApplication
.
class
,
args
);
}
}
@Override
public
void
run
(
String
...
strings
)
throws
Exception
{
try
{
log
.
info
(
"\n----------------------------------------------------------\n\t"
+
"Application '{}' is running! Access URLs:\n\t"
+
"Local: \t\thttp://127.0.0.1:{}\n\t"
+
"External: \thttp://{}:{}{}/doc.html\n\t"
+
"Profile(s): \t{}\n----------------------------------------------------------"
,
environment
.
getProperty
(
"spring.application.name"
),
environment
.
getProperty
(
"server.port"
),
InetAddress
.
getLocalHost
().
getHostAddress
(),
environment
.
getProperty
(
"server.port"
),
environment
.
getProperty
(
"server.servlet.context-path"
),
Arrays
.
toString
(
environment
.
getActiveProfiles
()));
}
catch
(
UnknownHostException
e
)
{
e
.
printStackTrace
();
}
}
}
}
liquidnet-bus-support/liquidnet-support-zuul/src/main/java/com/liquidnet/support/zuul/config/swagger/ZuulDocumentationConfig.java
0 → 100644
View file @
75b8d4f3
package
com
.
liquidnet
.
support
.
zuul
.
config
.
swagger
;
import
org.springframework.cloud.netflix.zuul.filters.Route
;
import
org.springframework.cloud.netflix.zuul.filters.RouteLocator
;
import
org.springframework.context.annotation.Primary
;
import
org.springframework.stereotype.Component
;
import
springfox.documentation.swagger.web.SwaggerResource
;
import
springfox.documentation.swagger.web.SwaggerResourcesProvider
;
import
java.util.ArrayList
;
import
java.util.List
;
@Primary
@Component
public
class
ZuulDocumentationConfig
implements
SwaggerResourcesProvider
{
private
final
RouteLocator
routeLocator
;
public
ZuulDocumentationConfig
(
RouteLocator
routeLocator
)
{
this
.
routeLocator
=
routeLocator
;
}
@Override
public
List
<
SwaggerResource
>
get
()
{
List
<
SwaggerResource
>
resources
=
new
ArrayList
<>();
List
<
Route
>
routes
=
routeLocator
.
getRoutes
();
routes
.
forEach
(
route
->
resources
.
add
(
swaggerResource
(
route
.
getId
(),
route
.
getFullPath
().
replace
(
"**"
,
"v2/api-docs"
))
));
// resources.add(swaggerResource("Adam", "/api/adam/v2/api-docs"));
// resources.add(swaggerResource("Kylin", "/api/kylin/v2/api-docs"));
return
resources
;
}
private
SwaggerResource
swaggerResource
(
String
name
,
String
location
)
{
SwaggerResource
swaggerResource
=
new
SwaggerResource
();
swaggerResource
.
setName
(
name
);
swaggerResource
.
setLocation
(
location
);
swaggerResource
.
setSwaggerVersion
(
"1.0"
);
return
swaggerResource
;
}
}
liquidnet-bus-support/liquidnet-support-zuul/src/main/java/com/liquidnet/support/zuul/config/swagger/ZuulSwagger2Config.java
0 → 100755
View file @
75b8d4f3
package
com
.
liquidnet
.
support
.
zuul
.
config
.
swagger
;
import
com.liquidnet.common.swagger.config.Swagger2Config
;
import
org.springframework.context.annotation.Configuration
;
@Configuration
public
class
ZuulSwagger2Config
extends
Swagger2Config
{
// @Override
// public ApiInfo apiInfo() {
// return new ApiInfoBuilder()
// .title("LiquidNet Services")
// .description("LiquidNet接口文档说明")
// .contact(new Contact("liquidnet", "", "**@liquidnet.io"))
// .version("1.0")
// .termsOfServiceUrl("http://localhost:8081")
// .build();
// }
//
// @Bean
// UiConfiguration uiConfig() {
// return new UiConfiguration(null, "list", "alpha", "schema",
// UiConfiguration.Constants.DEFAULT_SUBMIT_METHODS, false, true, 60000L);
// }
}
liquidnet-bus-support/liquidnet-support-zuul/src/main/java/com/liquidnet/support/zuul/filter/error/ErrorExtFilter.java
deleted
100644 → 0
View file @
7e633f3f
package
com
.
liquidnet
.
support
.
zuul
.
filter
.
error
;
import
com.netflix.zuul.ZuulFilter
;
import
com.netflix.zuul.context.RequestContext
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.cloud.netflix.zuul.filters.post.SendErrorFilter
;
import
org.springframework.stereotype.Component
;
/**
* 从POST抛出的异常,使用该过滤器返回错误信息
*/
@Component
public
class
ErrorExtFilter
extends
SendErrorFilter
{
Logger
log
=
LoggerFactory
.
getLogger
(
ErrorExtFilter
.
class
);
@Override
public
String
filterType
()
{
return
"error"
;
}
@Override
public
int
filterOrder
()
{
return
30
;
}
@Override
public
boolean
shouldFilter
()
{
RequestContext
ctx
=
RequestContext
.
getCurrentContext
();
ZuulFilter
failedFilter
=
(
ZuulFilter
)
ctx
.
get
(
"failed.filter"
);
if
(
failedFilter
!=
null
&&
failedFilter
.
filterType
().
equals
(
"post"
))
{
return
true
;
}
return
false
;
}
}
liquidnet-bus-support/liquidnet-support-zuul/src/main/java/com/liquidnet/support/zuul/filter/error/ErrorFilter.java
deleted
100644 → 0
View file @
7e633f3f
package
com
.
liquidnet
.
support
.
zuul
.
filter
.
error
;
import
com.netflix.zuul.ZuulFilter
;
import
com.netflix.zuul.context.RequestContext
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Component
;
import
javax.servlet.http.HttpServletResponse
;
/**
* 捕获为处理的异常统一做一些处理,让`SendErrorFilter`可以正确的返回异常信息
* 当是`post`过滤器抛出的话,错误信息会让`ErrorExtFilter`返回异常信息
*/
@Component
public
class
ErrorFilter
extends
ZuulFilter
{
Logger
log
=
LoggerFactory
.
getLogger
(
ErrorFilter
.
class
);
@Override
public
String
filterType
()
{
return
"error"
;
}
@Override
public
int
filterOrder
()
{
return
20
;
}
@Override
public
boolean
shouldFilter
()
{
return
true
;
}
@Override
public
Object
run
()
{
RequestContext
ctx
=
RequestContext
.
getCurrentContext
();
Throwable
throwable
=
RequestContext
.
getCurrentContext
().
getThrowable
();
log
.
error
(
"this is a ErrorFilter : {}"
,
throwable
.
getCause
().
getMessage
());
ctx
.
set
(
"error.status_code"
,
HttpServletResponse
.
SC_INTERNAL_SERVER_ERROR
);
ctx
.
set
(
"error.exception"
,
throwable
.
getCause
());
return
null
;
}
}
liquidnet-bus-support/liquidnet-support-zuul/src/main/java/com/liquidnet/support/zuul/filter/post/ThrowExceptionPostFilter.java
deleted
100644 → 0
View file @
7e633f3f
package
com
.
liquidnet
.
support
.
zuul
.
filter
.
post
;
import
com.netflix.zuul.ZuulFilter
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Component
;
@Component
public
class
ThrowExceptionPostFilter
extends
ZuulFilter
{
private
static
Logger
log
=
LoggerFactory
.
getLogger
(
ThrowExceptionPostFilter
.
class
);
@Override
public
String
filterType
()
{
return
"post"
;
}
@Override
public
int
filterOrder
()
{
return
10
;
}
@Override
public
boolean
shouldFilter
()
{
return
true
;
}
@Override
public
Object
run
()
{
log
.
info
(
"This is a post filter, it will throw a RuntimeException"
);
doSomething
();
return
null
;
}
private
void
doSomething
()
{
// throw new RuntimeException("Exist some errors...");
}
}
liquidnet-bus-support/liquidnet-support-zuul/src/main/java/com/liquidnet/support/zuul/filter/pre/ThrowExceptionFilter.java
deleted
100644 → 0
View file @
7e633f3f
package
com
.
liquidnet
.
support
.
zuul
.
filter
.
pre
;
import
com.netflix.zuul.ZuulFilter
;
import
com.netflix.zuul.context.RequestContext
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Component
;
import
javax.servlet.http.HttpServletResponse
;
@Component
public
class
ThrowExceptionFilter
extends
ZuulFilter
{
private
static
Logger
log
=
LoggerFactory
.
getLogger
(
ThrowExceptionFilter
.
class
);
@Override
public
String
filterType
()
{
return
"pre"
;
}
@Override
public
int
filterOrder
()
{
return
0
;
}
@Override
public
boolean
shouldFilter
()
{
return
true
;
}
@Override
public
Object
run
()
{
log
.
info
(
"This is a pre filter, it will throw a RuntimeException"
);
RequestContext
ctx
=
RequestContext
.
getCurrentContext
();
try
{
doSomething
();
}
catch
(
Exception
e
)
{
ctx
.
set
(
"error.status_code"
,
HttpServletResponse
.
SC_INTERNAL_SERVER_ERROR
);
ctx
.
set
(
"error.exception"
,
e
);
}
return
null
;
}
private
void
doSomething
()
{
// throw new RuntimeException("Exist some errors...");
}
}
liquidnet-bus-support/liquidnet-support-zuul/src/main/resources/application-test.yml
deleted
100644 → 0
View file @
7e633f3f
liquidnet
:
eureka
:
# serviceUrl: 127.0.0.1:7001/eureka-server/eureka
serviceUrl
:
192.168.31.229:7001/eureka-server/eureka
spring
:
profiles
:
include
:
zuul
\ No newline at end of file
liquidnet-bus-support/liquidnet-support-zuul/src/main/resources/application-zuul.yml
deleted
100644 → 0
View file @
7e633f3f
spring
:
application
:
name
:
liquidnet-gateway-zuul
security
:
basic
:
enabled
:
true
user
:
name
:
user
password
:
user123
server
:
port
:
7003
server
:
tomcat
:
accept-count
:
500
max-threads
:
500
min-spare-threads
:
100
max-connections
:
1000
connection-timeout
:
5000
eureka
:
client
:
healthcheck
:
enabled
:
true
register-with-eureka
:
true
fetch-registry
:
true
serviceUrl
:
# defaultZone: ${liquidnet.eureka.serviceUrl}
defaultZone
:
http://${spring.security.user.name}:${spring.security.user.password}@${liquidnet.eureka.serviceUrl}
instance
:
hostname
:
${spring.cloud.client.ip-address}
lease-expiration-duration-in-seconds
:
15
#服务过期时间配置,超过这个时间没有接收到心跳EurekaServer就会将这个实例剔除
lease-renewal-interval-in-seconds
:
5
#服务刷新时间配置,每隔这个时间会主动心跳一次
prefer-ip-address
:
true
instance-id
:
${spring.application.name}:${spring.cloud.client.ip-address}:${spring.application.instance_id:${server.port}}
zuul
:
prefix
:
/liquidnet-api
host
:
max-per-route-connections
:
1000
max-total-connections
:
2000
routes
:
liquidnet-service-adam
:
/adam/**
liquidnet-service-sequence
:
/sequence/**
liquidnet-service-example
:
/example/**
liquidnet-service-account
:
/account/**
liquidnet-service-task
:
/task/**
ThrowExceptionPostFilter
:
post
:
disable
:
true
#解决错误 com.netflix.client.ClientException: Load balancer does not have available server for client:panfeng-item-service
#这样就可以即指定path与URL,又不破坏Zuul的Hystrix与Ribbon特性了。
#开启eureka负载均衡策略
ribbon
:
eureka
:
enabled
:
false
# 为Ribbon禁用Eureka
liquidnet-service-sequence
:
ribbon
:
listOfServers
:
192.168.137.1:9001
logging
:
level
:
com.netflix
:
debug
#zuul:
# prefix: /api
# strip-prefix: false
liquidnet-bus-support/liquidnet-support-zuul/src/main/resources/application.yml
deleted
100644 → 0
View file @
7e633f3f
spring
:
profiles
:
active
:
test
\ No newline at end of file
liquidnet-bus-support/liquidnet-support-zuul/src/main/resources/banner.txt
deleted
100644 → 0
View file @
7e633f3f
/$$ /$$ /$$ /$$ /$$ /$$ /$$
| $$ |__/ |__/ | $$| $$$ | $$ | $$
| $$ /$$ /$$$$$$ /$$ /$$ /$$ /$$$$$$$| $$$$| $$ /$$$$$$ /$$$$$$
| $$ | $$ /$$__ $$| $$ | $$| $$ /$$__ $$| $$ $$ $$ /$$__ $$|_ $$_/
| $$ | $$| $$ \ $$| $$ | $$| $$| $$ | $$| $$ $$$$| $$$$$$$$ | $$
| $$ | $$| $$ | $$| $$ | $$| $$| $$ | $$| $$\ $$$| $$_____/ | $$ /$$
| $$$$$$$$| $$| $$$$$$$| $$$$$$/| $$| $$$$$$$| $$ \ $$| $$$$$$$ | $$$$/
|________/|__/ \____ $$ \______/ |__/ \_______/|__/ \__/ \_______/ \___/
| $$
| $$
|__/
Application Version: ${application.version}${application.formatted-version}
Spring Boot Version: ${spring-boot.version}${spring-boot.formatted-version}
liquidnet-bus-support/liquidnet-support-zuul/src/main/resources/bootstrap-dev.yml
0 → 100755
View file @
75b8d4f3
# begin-dev-这里是配置信息基本值
liquidnet
:
cloudConfig
:
profile
:
dev
security
:
username
:
user
password
:
user123
eureka
:
host
:
127.0.0.1:7001
# end-dev-这里是配置信息基本值
spring
:
profiles
:
include
:
support-zuul
\ No newline at end of file
liquidnet-bus-support/liquidnet-support-zuul/src/main/resources/bootstrap-prod.yml
View file @
75b8d4f3
## ===================================================================
# begin-dev-这里是配置信息基本值
## Spring Cloud Config bootstrap configuration for the "dev" profile
liquidnet
:
## In prod profile, properties will be overwriten by the ones defined in bootstrap-prod.yml
cloudConfig
:
## ===================================================================
profile
:
prod
#
security
:
#spring:
username
:
user
# application:
password
:
user123
# name: liquidnet-gateway-zuul
eureka
:
# profiles:
host
:
127.0.0.1:7001
# active: prod
# end-dev-这里是配置信息基本值
# cloud:
# config:
spring
:
# # name of the config server's property source (file.yml) that we want to use
profiles
:
# profile: prod # profile(s) of the property source
include
:
service-zuul
# label: master # toggle to switch to a different version of the configuration as stored in git
\ No newline at end of file
# uri: http://172.24.132.45:20001/
# # it can be set to any label, branch or commit of the config source git repository
#
liquidnet-bus-support/liquidnet-support-zuul/src/main/resources/bootstrap-support-zuul.yml
0 → 100755
View file @
75b8d4f3
#eurekaServer配置
eureka
:
client
:
register-with-eureka
:
true
fetch-registry
:
true
serviceUrl
:
defaultZone
:
http://${liquidnet.security.username}:${liquidnet.security.password}@${liquidnet.eureka.host}/eureka-server/eureka
#configServer配置
spring
:
cloud
:
config
:
# uri: http://127.0.0.1:7002/support-config
profile
:
${liquidnet.cloudConfig.profile}
name
:
${spring.application.name}
#默认为spring.application.name
discovery
:
enabled
:
true
service-id
:
liquidnet-support-config
\ No newline at end of file
liquidnet-bus-support/liquidnet-support-zuul/src/main/resources/bootstrap-test.yml
View file @
75b8d4f3
## ===================================================================
# begin-dev-这里是配置信息基本值
## Spring Cloud Config bootstrap configuration for the "dev" profile
liquidnet
:
## In prod profile, properties will be overwriten by the ones defined in bootstrap-prod.yml
cloudConfig
:
## ===================================================================
profile
:
test
#
security
:
#spring:
username
:
user
# application:
password
:
user123
# name: liquidnet-gateway-zuul
eureka
:
# profiles:
host
:
172.18.0.2:7001
# active: test
# end-dev-这里是配置信息基本值
# cloud:
# config:
spring
:
# label: ${spring.profiles.active1:dev} #当配置文件在git上时为分支名
profiles
:
## profile: ${spring.profiles.active1:dev} #对应业务名称的profile
include
:
service-zuul
# uri: http://172.24.133.63:20001/
\ No newline at end of file
## discovery: # 需要考虑 eureka 地址的初始化 先不使用
## enabled: true # 默认false,设为true表示使用注册中心中的configserver配置而不自己配置configserver的uri
## serviceId: liquidnet-config-service # 指定config server在服务发现中的serviceId,默认为:configserver
liquidnet-bus-support/liquidnet-support-zuul/src/main/resources/bootstrap.yml
View file @
75b8d4f3
#
spring
:
#spring:
application
:
# application:
name
:
liquidnet-support-zuul
# name: liquidnet-gateway-zuul
profiles
:
# profiles:
active
:
dev
# active: dev
# cloud:
# config:
# label: ${spring.profiles.active1:dev} #当配置文件在git上时为分支名
## profile: ${spring.profiles.active1:dev} #对应业务名称的profile
# uri: http://172.24.132.45:20001/
## discovery: # 需要考虑 eureka 地址的初始化 先不使用
## enabled: true # 默认false,设为true表示使用注册中心中的configserver配置而不自己配置configserver的uri
## serviceId: liquidnet-config-service # 指定config server在服务发现中的serviceId,默认为:configserver
liquidnet-bus-support/liquidnet-support-zuul/src/main/resources/logback.xml
deleted
100644 → 0
View file @
7e633f3f
<!-- Logback configuration. See http://logback.qos.ch/manual/index.html -->
<configuration
scan=
"true"
scanPeriod=
"10 seconds"
>
<!-- Simple file output -->
<appender
name=
"FILE"
class=
"ch.qos.logback.core.rolling.RollingFileAppender"
>
<!-- encoder defaults to ch.qos.logback.classic.encoder.PatternLayoutEncoder -->
<encoder>
<pattern>
[ %-5level] [%date{yyyy-MM-dd HH:mm:ss}] %logger{96} [%line] - %msg%n
</pattern>
<charset>
UTF-8
</charset>
<!-- 此处设置字符集 -->
</encoder>
<rollingPolicy
class=
"ch.qos.logback.core.rolling.TimeBasedRollingPolicy"
>
<!-- rollover daily 配置日志所生成的目录以及生成文件名的规则 -->
<fileNamePattern>
/data/logs/YGZX/dubbo/liquidnet-gateway-zuul/liquidnet-gateway-zuul-%d{yyyy-MM-dd}.%i.log
</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy
class=
"ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"
>
<!-- or whenever the file size reaches 64 MB -->
<maxFileSize>
64 MB
</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<filter
class=
"ch.qos.logback.classic.filter.ThresholdFilter"
>
<level>
DEBUG
</level>
</filter>
<!-- Safely log to the same file from multiple JVMs. Degrades performance! -->
<prudent>
true
</prudent>
</appender>
<!-- Console output -->
<appender
name=
"STDOUT"
class=
"ch.qos.logback.core.ConsoleAppender"
>
<!-- encoder defaults to ch.qos.logback.classic.encoder.PatternLayoutEncoder -->
<encoder>
<pattern>
[ %-5level] [%date{yyyy-MM-dd HH:mm:ss}] %logger{96} [%line] - %msg%n
</pattern>
<charset>
UTF-8
</charset>
<!-- 此处设置字符集 -->
</encoder>
<!-- Only log level WARN and above -->
<!--<filter class="ch.qos.logback.classic.filter.ThresholdFilter">-->
<!--<level>WARN</level>-->
<!--</filter>-->
</appender>
<!-- Enable FILE and STDOUT appenders for all log messages.
By default, only log at level INFO and above. -->
<root
level=
"INFO"
>
<appender-ref
ref=
"FILE"
/>
<appender-ref
ref=
"STDOUT"
/>
</root>
<!-- For loggers in the these namespaces, log at all levels. -->
<!--<logger name="pedestal" level="ALL"/>-->
<!--<logger name="hammock-cafe" level="ALL"/>-->
<!--<logger name="user" level="ALL"/>-->
</configuration>
liquidnet-bus-support/pom.xml
View file @
75b8d4f3
...
@@ -44,6 +44,11 @@
...
@@ -44,6 +44,11 @@
<artifactId>
spring-boot-starter-test
</artifactId>
<artifactId>
spring-boot-starter-test
</artifactId>
<scope>
test
</scope>
<scope>
test
</scope>
</dependency>
</dependency>
<dependency>
<groupId>
com.google.guava
</groupId>
<artifactId>
guava
</artifactId>
<version>
29.0-jre
</version>
</dependency>
<dependency>
<dependency>
<groupId>
org.projectlombok
</groupId>
<groupId>
org.projectlombok
</groupId>
<artifactId>
lombok
</artifactId>
<artifactId>
lombok
</artifactId>
...
...
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