Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
xyqb-user2
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
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
head_group
xyqb-user2
Commits
a81cfd80
Commit
a81cfd80
authored
May 22, 2018
by
技术部-任文超
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
完成zipkin接入
parent
b20fe017
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
56 additions
and
39 deletions
+56
-39
pom.xml
pom.xml
+1
-5
Bootstrap.java
src/main/java/cn/quantgroup/xyqb/Bootstrap.java
+3
-16
HttpConfig.java
src/main/java/cn/quantgroup/xyqb/config/http/HttpConfig.java
+6
-1
LoanVestMQConfig.java
...n/java/cn/quantgroup/xyqb/config/mq/LoanVestMQConfig.java
+7
-3
RegisterMqConfig.java
...n/java/cn/quantgroup/xyqb/config/mq/RegisterMqConfig.java
+8
-2
SentryConfig.java
...n/java/cn/quantgroup/xyqb/config/sentry/SentryConfig.java
+18
-7
HttpServiceImpl.java
...cn/quantgroup/xyqb/service/http/impl/HttpServiceImpl.java
+6
-1
LoanVestMQServiceImpl.java
...uantgroup/xyqb/service/mq/Impl/LoanVestMQServiceImpl.java
+2
-2
TestUserLogin.java
src/test/java/login/TestUserLogin.java
+5
-2
No files found.
pom.xml
View file @
a81cfd80
...
...
@@ -14,7 +14,7 @@
<parent>
<groupId>
cn.quantgroup
</groupId>
<artifactId>
commons-parent
</artifactId>
<version>
0.2.
3
</version>
<version>
0.2.
4
</version>
</parent>
<properties>
...
...
@@ -272,10 +272,6 @@
<groupId>
cn.quantgroup
</groupId>
<artifactId>
shutdown-spring-boot-starter
</artifactId>
</dependency>
<dependency>
<groupId>
cn.quantgroup
</groupId>
<artifactId>
idgenerator-spring-boot-starter
</artifactId>
</dependency>
<dependency>
<groupId>
cn.quantgroup
</groupId>
<artifactId>
brave-spring-boot-starter
</artifactId>
...
...
src/main/java/cn/quantgroup/xyqb/Bootstrap.java
View file @
a81cfd80
package
cn
.
quantgroup
.
xyqb
;
import
cn.quantgroup.tech.shutdown.DefaultSignalHandler
;
import
com.weibo.api.motan.common.MotanConstants
;
import
com.weibo.api.motan.util.MotanSwitcherUtil
;
import
io.sentry.Sentry
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.cache.annotation.EnableCaching
;
import
org.springframework.context.ApplicationListener
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
org.springframework.context.annotation.ComponentScan
;
import
org.springframework.context.annotation.EnableAspectJAutoProxy
;
import
org.springframework.context.event.ContextRefreshedEvent
;
import
org.springframework.core.env.Environment
;
import
org.springframework.scheduling.annotation.EnableAsync
;
import
sun.misc.Signal
;
/**
* @author Anonymous
...
...
@@ -24,9 +19,9 @@ import sun.misc.Signal;
* -Denv=dev -Didc=k8s -Dlogging.config=classpath:logback-dev.xml -DNAMESPACE=xxx -Dserver.port=8099
*/
@Slf4j
@
EnableAsync
@
ComponentScan
(
basePackages
=
{
"cn.quantgroup.sms"
,
"cn.quantgroup.xyqb"
})
@EnableCaching
@
ComponentScan
(
basePackages
=
{
"cn.quantgroup.sms"
,
"cn.quantgroup.xyqb"
,
"cn.quantgroup.tech"
})
@
EnableAsync
@EnableAspectJAutoProxy
@SpringBootApplication
public
class
Bootstrap
{
...
...
@@ -40,15 +35,7 @@ public class Bootstrap {
log
.
info
(
"注册zookeeper成功"
);
}
});
springApplication
.
setRegisterShutdownHook
(
true
);
ConfigurableApplicationContext
run
=
springApplication
.
run
(
args
);
log
.
info
(
"server start..."
);
// 启用平滑退出功能
Signal
.
handle
(
new
Signal
(
"INT"
),
new
DefaultSignalHandler
(
run
));
// 异常log捕获
Environment
environment
=
run
.
getBean
(
Environment
.
class
);
String
dsn
=
environment
.
getProperty
(
"dsn"
);
Sentry
.
init
(
dsn
);
springApplication
.
run
(
args
);
}
}
src/main/java/cn/quantgroup/xyqb/config/http/HttpConfig.java
View file @
a81cfd80
package
cn
.
quantgroup
.
xyqb
.
config
.
http
;
import
cn.quantgroup.tech.brave.service.ITechHttpClient
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
com.fasterxml.jackson.databind.DeserializationFeature
;
import
com.fasterxml.jackson.databind.SerializationFeature
;
...
...
@@ -35,6 +36,7 @@ import org.springframework.format.support.FormattingConversionService;
import
org.springframework.http.converter.json.Jackson2ObjectMapperBuilder
;
import
org.springframework.web.filter.CharacterEncodingFilter
;
import
javax.annotation.Resource
;
import
javax.net.ssl.SSLContext
;
import
java.security.KeyManagementException
;
import
java.security.KeyStoreException
;
...
...
@@ -46,6 +48,9 @@ import java.text.SimpleDateFormat;
*/
@Configuration
public
class
HttpConfig
{
//注入brave-spring-boot-starter提供的techHttpClient
@Resource
private
ITechHttpClient
techHttpClient
;
@Bean
public
FilterRegistrationBean
filterRegistrationBean
()
{
...
...
@@ -137,7 +142,7 @@ public class HttpConfig {
ConnectionKeepAliveStrategy
keepAliveStrategy
=
new
DefaultConnectionKeepAliveStrategy
();
// httpclient
return
HttpClients
.
custom
()
return
techHttpClient
.
createHttpClientBuilder
()
.
setConnectionManager
(
connectionManager
)
.
setRetryHandler
(
retryHandler
)
.
setKeepAliveStrategy
(
keepAliveStrategy
)
...
...
src/main/java/cn/quantgroup/xyqb/config/mq/LoanVestMQConfig.java
View file @
a81cfd80
package
cn
.
quantgroup
.
xyqb
.
config
.
mq
;
import
cn.quantgroup.tech.brave.service.ITechRabbitBuilder
;
import
org.springframework.amqp.core.*
;
import
org.springframework.amqp.rabbit.connection.CachingConnectionFactory
;
import
org.springframework.amqp.rabbit.connection.ConnectionFactory
;
...
...
@@ -11,6 +12,8 @@ import org.springframework.context.annotation.Bean;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Primary
;
import
javax.annotation.Resource
;
/**
* //马甲包 xuran
*/
...
...
@@ -32,8 +35,9 @@ public class LoanVestMQConfig {
private
String
password
;
@Value
(
"${loanvest.rabbitmq.connection.virtual-host}"
)
private
String
virtualHost
;
//@Value("${loanvest.rabbitmq.stateMsgQueue}")
//private String stateQueueName;
@Resource
private
ITechRabbitBuilder
techRabbitBuilder
;
@Primary
@Bean
(
name
=
"vestFactory"
)
...
...
@@ -80,7 +84,7 @@ public class LoanVestMQConfig {
@Primary
@Bean
(
name
=
"rabbitTemplate"
)
public
RabbitTemplate
loanVestTemplate
(
@Qualifier
(
"vestFactory"
)
ConnectionFactory
vestFactory
)
{
RabbitTemplate
template
=
new
RabbitTemplate
(
vestFactory
);
RabbitTemplate
template
=
techRabbitBuilder
.
create
RabbitTemplate
(
vestFactory
);
template
.
setExchange
(
loanVestExchange
);
return
template
;
}
...
...
src/main/java/cn/quantgroup/xyqb/config/mq/RegisterMqConfig.java
View file @
a81cfd80
package
cn
.
quantgroup
.
xyqb
.
config
.
mq
;
import
cn.quantgroup.tech.brave.service.ITechRabbitBuilder
;
import
org.springframework.amqp.core.*
;
import
org.springframework.amqp.rabbit.connection.CachingConnectionFactory
;
import
org.springframework.amqp.rabbit.connection.ConnectionFactory
;
...
...
@@ -10,6 +11,8 @@ import org.springframework.beans.factory.annotation.Value;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
javax.annotation.Resource
;
/**
* Created by xuran on 2017/9/7.
*/
...
...
@@ -37,6 +40,9 @@ public class RegisterMqConfig {
@Value
(
"${register.rabbitmq.connection.virtual-host}"
)
private
String
virtualHost
;
@Resource
private
ITechRabbitBuilder
techRabbitBuilder
;
@Bean
(
name
=
"registerMqFactory"
)
public
ConnectionFactory
registerMqFactory
()
{
...
...
@@ -77,7 +83,7 @@ public class RegisterMqConfig {
@Bean
(
name
=
"registerRabbitTemplate"
)
public
RabbitTemplate
registerTemplate
(
@Qualifier
(
"registerMqFactory"
)
ConnectionFactory
registerMqFactory
)
{
RabbitTemplate
template
=
new
RabbitTemplate
(
registerMqFactory
);
RabbitTemplate
template
=
techRabbitBuilder
.
create
RabbitTemplate
(
registerMqFactory
);
template
.
setExchange
(
registerMqExchange
);
return
template
;
}
...
...
@@ -103,7 +109,7 @@ public class RegisterMqConfig {
@Bean
(
name
=
"registerRabbitTemplate4Gdt"
)
public
RabbitTemplate
registerTemplate4Gdt
(
@Qualifier
(
"registerMqFactory"
)
ConnectionFactory
registerMqFactory
)
{
RabbitTemplate
template
=
new
RabbitTemplate
(
registerMqFactory
);
RabbitTemplate
template
=
techRabbitBuilder
.
create
RabbitTemplate
(
registerMqFactory
);
template
.
setExchange
(
exchange4Gdt
);
return
template
;
}
...
...
src/main/java/cn/quantgroup/xyqb/config/sentry/SentryConfig.java
View file @
a81cfd80
package
cn
.
quantgroup
.
xyqb
.
config
.
sentry
;
import
org.springframework.boot.autoconfigure.EnableAutoConfiguration
;
import
org.springframework.b
oot.autoconfigure.SpringBootApplication
;
import
io.sentry.Sentry
;
import
org.springframework.b
eans.factory.annotation.Value
;
import
org.springframework.boot.web.servlet.ServletContextInitializer
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.
stereotype.Controller
;
import
org.springframework.
context.annotation.Configuration
;
import
org.springframework.web.servlet.HandlerExceptionResolver
;
import
javax.annotation.PostConstruct
;
/**
* @author xufei on 2017/12/27.
* 初始化Sentry配置
* @author renwc
* @date 2018-05-22
*/
@Controller
@EnableAutoConfiguration
@SpringBootApplication
@Configuration
public
class
SentryConfig
{
@Value
(
"${dsn}"
)
private
String
dsn
;
@Bean
public
HandlerExceptionResolver
sentryExceptionResolver
()
{
return
new
io
.
sentry
.
spring
.
SentryExceptionResolver
();
...
...
@@ -23,4 +29,9 @@ public class SentryConfig {
public
ServletContextInitializer
sentryServletContextInitializer
()
{
return
new
io
.
sentry
.
spring
.
SentryServletContextInitializer
();
}
@PostConstruct
public
void
initSentry
(){
Sentry
.
init
(
dsn
);
}
}
src/main/java/cn/quantgroup/xyqb/service/http/impl/HttpServiceImpl.java
View file @
a81cfd80
package
cn
.
quantgroup
.
xyqb
.
service
.
http
.
impl
;
import
cn.quantgroup.tech.brave.service.ITechHttpClient
;
import
cn.quantgroup.xyqb.service.http.IHttpService
;
import
cn.quantgroup.xyqb.util.Utils
;
import
com.google.common.base.Predicates
;
...
...
@@ -43,6 +44,7 @@ import org.slf4j.Logger;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
javax.net.ssl.SSLContext
;
import
java.security.KeyManagementException
;
import
java.security.KeyStoreException
;
...
...
@@ -62,6 +64,9 @@ public class HttpServiceImpl implements IHttpService {
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
HttpServiceImpl
.
class
);
private
static
final
int
TIME_OUT
=
60
*
1000
;
// 超时时间
//注入brave-spring-boot-starter提供的techHttpClient
@Resource
private
ITechHttpClient
techHttpClient
;
@Override
public
String
get
(
String
uri
)
{
...
...
@@ -191,7 +196,7 @@ public class HttpServiceImpl implements IHttpService {
ConnectionKeepAliveStrategy
keepAliveStrategy
=
new
DefaultConnectionKeepAliveStrategy
();
// httpclient
return
HttpClients
.
custom
()
return
techHttpClient
.
createHttpClientBuilder
()
.
setConnectionManager
(
connectionManager
)
.
setRetryHandler
(
retryHandler
)
.
setKeepAliveStrategy
(
keepAliveStrategy
)
...
...
src/main/java/cn/quantgroup/xyqb/service/mq/Impl/LoanVestMQServiceImpl.java
View file @
a81cfd80
...
...
@@ -23,7 +23,7 @@ public class LoanVestMQServiceImpl implements IVestService {
@Resource
@Qualifier
(
"rabbitTemplate"
)
private
RabbitTemplate
loanVestR
abbitTemplate
;
private
RabbitTemplate
r
abbitTemplate
;
@Resource
@Qualifier
(
value
=
"loanVestQueue"
)
...
...
@@ -42,7 +42,7 @@ public class LoanVestMQServiceImpl implements IVestService {
}
LOGGER
.
info
(
"用户登陆统计发送,message={}"
,
message
);
String
msg
=
JSONObject
.
toJSONString
(
message
);
loanVestR
abbitTemplate
.
convertAndSend
(
"statistics-user"
,
msg
);
r
abbitTemplate
.
convertAndSend
(
"statistics-user"
,
msg
);
LOGGER
.
info
(
"用户登陆统计成功,message={}"
,
msg
);
}
...
...
src/test/java/login/TestUserLogin.java
View file @
a81cfd80
package
login
;
import
cn.quantgroup.tech.brave.service.ITechHttpClient
;
import
cn.quantgroup.xyqb.Bootstrap
;
import
cn.quantgroup.xyqb.Constants
;
import
cn.quantgroup.xyqb.controller.external.user.InnerController
;
...
...
@@ -44,6 +45,9 @@ public class TestUserLogin {
@Resource
private
InnerController
innerController
;
//注入brave-spring-boot-starter提供的techHttpClient
@Resource
private
ITechHttpClient
techHttpClient
;
@Test
public
void
testBull
()
{
...
...
@@ -82,8 +86,7 @@ public class TestUserLogin {
String
token
=
authBean
.
getToken
();
System
.
out
.
println
(
"user token:"
+
token
);
//用获取到的token请求xyqb的receive_token
CloseableHttpClient
httpClient
=
HttpClients
.
createDefault
();
CloseableHttpClient
httpClient
=
techHttpClient
.
createHttpClientBuilder
().
build
();
HttpPost
post
=
new
HttpPost
(
"http://localhost:9004/ex/login/receive_token"
);
List
<
NameValuePair
>
pairList
=
new
ArrayList
<>();
...
...
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