Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
matrix-sample
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
mall
arch
matrix-sample
Commits
0d4b21cc
Commit
0d4b21cc
authored
Mar 16, 2020
by
qiuweili123
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加dubbo-demo
parent
e8f4fb9d
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
331 additions
and
4 deletions
+331
-4
UserDto.java
matrix-sample-dubbo/matrix-sample-dubbo-api/src/main/java/com/secoo/mall/dubbo/dto/UserDto.java
+2
-2
UserDService.java
matrix-sample-dubbo/matrix-sample-dubbo-api/src/main/java/com/secoo/mall/dubbo/service/UserDService.java
+3
-2
pom.xml
matrix-sample-dubbo/matrix-sample-dubbo-biz/pom.xml
+27
-0
DemoResponseExceptionFilter.java
matrix-sample-dubbo/matrix-sample-dubbo-biz/src/main/java/com/secoo/mall/dubbo/filter/DemoResponseExceptionFilter.java
+15
-0
DemoWarnExceptionFilter.java
matrix-sample-dubbo/matrix-sample-dubbo-biz/src/main/java/com/secoo/mall/dubbo/filter/DemoWarnExceptionFilter.java
+14
-0
UserService.java
matrix-sample-dubbo/matrix-sample-dubbo-biz/src/main/java/com/secoo/mall/dubbo/service/UserService.java
+36
-0
org.apache.dubbo.rpc.Filter
matrix-sample-dubbo/matrix-sample-dubbo-biz/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.rpc.Filter
+3
-0
pom.xml
matrix-sample-dubbo/matrix-sample-dubbo-springboot/matrix-sample-dubbo-springboot-c/pom.xml
+26
-0
DubboConsumerBootstrap.java
matrix-sample-dubbo/matrix-sample-dubbo-springboot/matrix-sample-dubbo-springboot-c/src/main/java/com/secoo/mall/dubbo/DubboConsumerBootstrap.java
+28
-0
UserServiceClient.java
matrix-sample-dubbo/matrix-sample-dubbo-springboot/matrix-sample-dubbo-springboot-c/src/main/java/com/secoo/mall/dubbo/client/UserServiceClient.java
+25
-0
application.properties
matrix-sample-dubbo/matrix-sample-dubbo-springboot/matrix-sample-dubbo-springboot-c/src/main/resources/application.properties
+6
-0
log4j.properties
matrix-sample-dubbo/matrix-sample-dubbo-springboot/matrix-sample-dubbo-springboot-c/src/main/resources/log4j.properties
+8
-0
pom.xml
matrix-sample-dubbo/matrix-sample-dubbo-springboot/matrix-sample-dubbo-springboot-p/pom.xml
+26
-0
DubboProviderBootstrap.java
matrix-sample-dubbo/matrix-sample-dubbo-springboot/matrix-sample-dubbo-springboot-p/src/main/java/com/secoo/mall/dubbo/DubboProviderBootstrap.java
+17
-0
UserProvider.java
matrix-sample-dubbo/matrix-sample-dubbo-springboot/matrix-sample-dubbo-springboot-p/src/main/java/com/secoo/mall/dubbo/provider/UserProvider.java
+45
-0
application.properties
matrix-sample-dubbo/matrix-sample-dubbo-springboot/matrix-sample-dubbo-springboot-p/src/main/resources/application.properties
+20
-0
log4j.properties
matrix-sample-dubbo/matrix-sample-dubbo-springboot/matrix-sample-dubbo-springboot-p/src/main/resources/log4j.properties
+8
-0
pom.xml
matrix-sample-dubbo/matrix-sample-dubbo-springboot/pom.xml
+6
-0
pom.xml
matrix-sample-dubbo/pom.xml
+16
-0
No files found.
matrix-sample-dubbo/matrix-sample-dubbo-api/src/main/java/com/secoo/mall/dubbo/
bean/User
.java
→
matrix-sample-dubbo/matrix-sample-dubbo-api/src/main/java/com/secoo/mall/dubbo/
dto/UserDto
.java
View file @
0d4b21cc
package
com
.
secoo
.
mall
.
dubbo
.
bean
;
package
com
.
secoo
.
mall
.
dubbo
.
dto
;
import
io.swagger.annotations.ApiModelProperty
;
import
io.swagger.annotations.ApiModelProperty
;
import
java.io.Serializable
;
import
java.io.Serializable
;
public
class
User
implements
Serializable
{
public
class
User
Dto
implements
Serializable
{
@ApiModelProperty
(
value
=
"用户姓名"
)
@ApiModelProperty
(
value
=
"用户姓名"
)
private
String
name
;
private
String
name
;
...
...
matrix-sample-dubbo/matrix-sample-dubbo-api/src/main/java/com/secoo/mall/dubbo/service/UserDService.java
View file @
0d4b21cc
package
com
.
secoo
.
mall
.
dubbo
.
service
;
package
com
.
secoo
.
mall
.
dubbo
.
service
;
import
com.secoo.mall.common.core.bean.BizResponse
;
import
com.secoo.mall.common.core.bean.BizResponse
;
import
com.secoo.mall.dubbo.
bean.User
;
import
com.secoo.mall.dubbo.
dto.UserDto
;
public
interface
UserDService
{
public
interface
UserDService
{
BizResponse
<
String
>
sayHello
(
String
name
);
BizResponse
<
String
>
sayHello
(
String
name
);
User
getByid
(
Long
id
);
User
Dto
getByid
(
Long
id
);
}
}
\ No newline at end of file
matrix-sample-dubbo/matrix-sample-dubbo-biz/pom.xml
0 → 100644
View file @
0d4b21cc
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<parent>
<artifactId>
matrix-sample-dubbo
</artifactId>
<groupId>
com.secoo.mall
</groupId>
<version>
1.3.2.RELEASE
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
matrix-sample-dubbo-biz
</artifactId>
<dependencies>
<dependency>
<groupId>
com.secoo.mall
</groupId>
<artifactId>
matrix-protocol-dubbo-starter
</artifactId>
</dependency>
<dependency>
<groupId>
com.secoo.mall
</groupId>
<artifactId>
matrix-sample-dubbo-api
</artifactId>
</dependency>
</dependencies>
</project>
\ No newline at end of file
matrix-sample-dubbo/matrix-sample-dubbo-biz/src/main/java/com/secoo/mall/dubbo/filter/DemoResponseExceptionFilter.java
0 → 100644
View file @
0d4b21cc
package
com
.
secoo
.
mall
.
dubbo
.
filter
;
import
org.apache.dubbo.common.constants.CommonConstants
;
import
org.apache.dubbo.common.extension.Activate
;
/**
* 统一拦截异常。
* 不向消费端抛出异常,而是形成response结构.
* 启用自动激活
*/
@Activate
(
group
=
{
CommonConstants
.
PROVIDER
}
)
public
class
DemoResponseExceptionFilter
extends
MatrixResponseExceptionFilter
{
}
matrix-sample-dubbo/matrix-sample-dubbo-biz/src/main/java/com/secoo/mall/dubbo/filter/DemoWarnExceptionFilter.java
0 → 100644
View file @
0d4b21cc
package
com
.
secoo
.
mall
.
dubbo
.
filter
;
import
org.apache.dubbo.common.constants.CommonConstants
;
import
org.apache.dubbo.common.extension.Activate
;
/**
* 将业务抛出的runtimeException由warn进行输出。
* 如果使用需要激活@Activate
*/
/*@Activate(
group = {CommonConstants.PROVIDER}
)*/
public
class
DemoWarnExceptionFilter
extends
MatrixExceptionFilter
{
}
matrix-sample-dubbo/matrix-sample-dubbo-biz/src/main/java/com/secoo/mall/dubbo/service/UserService.java
0 → 100644
View file @
0d4b21cc
package
com
.
secoo
.
mall
.
dubbo
.
service
;
import
com.secoo.mall.common.core.errorcode.ErrorCode
;
import
com.secoo.mall.common.core.exception.BusinessException
;
import
com.secoo.mall.dubbo.dto.UserDto
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.dubbo.rpc.RpcContext
;
import
org.springframework.stereotype.Service
;
//import com.secoo.mall.common.util.web.WebUtil;
@Service
@Slf4j
public
class
UserService
{
public
String
sayHello
(
String
name
)
{
//模拟抛出异常
if
(
true
)
{
ErrorCode
errorCode
=
new
ErrorCode
(
1
,
"project_not_exist"
);
throw
new
BusinessException
(
errorCode
);
}
log
.
info
(
"Hello {}, request from consumer: {}"
,
name
,
RpcContext
.
getContext
().
getRemoteAddress
());
return
"Hello "
+
name
+
", response from provider: "
+
RpcContext
.
getContext
().
getLocalAddress
();
}
public
UserDto
getById
(
Long
id
)
{
//正常情况下需要做bean到DTO的BeanCopy
UserDto
u
=
new
UserDto
();
u
.
setName
(
"liqiuweitest"
);
return
u
;
}
}
matrix-sample-dubbo/matrix-sample-dubbo-biz/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.rpc.Filter
0 → 100644
View file @
0d4b21cc
warnException=com.secoo.mall.dubbo.filter.DemoWarnExceptionFilter
responseException=com.secoo.mall.dubbo.filter.DemoResponseExceptionFilter
\ No newline at end of file
matrix-sample-dubbo/matrix-sample-dubbo-springboot/matrix-sample-dubbo-springboot-c/pom.xml
0 → 100644
View file @
0d4b21cc
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<parent>
<artifactId>
matrix-sample-dubbo-springboot
</artifactId>
<groupId>
com.secoo.mall
</groupId>
<version>
1.3.2.RELEASE
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
matrix-sample-dubbo-springboot-c
</artifactId>
<dependencies>
<dependency>
<groupId>
com.secoo.mall
</groupId>
<artifactId>
matrix-protocol-dubbo-starter
</artifactId>
</dependency>
<dependency>
<groupId>
com.secoo.mall
</groupId>
<artifactId>
matrix-sample-dubbo-api
</artifactId>
</dependency>
</dependencies>
</project>
\ No newline at end of file
matrix-sample-dubbo/matrix-sample-dubbo-springboot/matrix-sample-dubbo-springboot-c/src/main/java/com/secoo/mall/dubbo/DubboConsumerBootstrap.java
0 → 100644
View file @
0d4b21cc
package
com
.
secoo
.
mall
.
dubbo
;
import
com.secoo.mall.dubbo.client.UserServiceClient
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.boot.ApplicationArguments
;
import
org.springframework.boot.ApplicationRunner
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
javax.annotation.Resource
;
@SpringBootApplication
@Slf4j
public
class
DubboConsumerBootstrap
implements
ApplicationRunner
{
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
DubboConsumerBootstrap
.
class
).
close
();
}
@Resource
private
UserServiceClient
userServiceClient
;
@Override
public
void
run
(
ApplicationArguments
args
)
throws
Exception
{
log
.
info
(
"ret:{}"
,
userServiceClient
.
sayHello
(
"hello"
));
}
}
matrix-sample-dubbo/matrix-sample-dubbo-springboot/matrix-sample-dubbo-springboot-c/src/main/java/com/secoo/mall/dubbo/client/UserServiceClient.java
0 → 100644
View file @
0d4b21cc
package
com
.
secoo
.
mall
.
dubbo
.
client
;
import
com.secoo.mall.common.core.bean.BizResponse
;
import
com.secoo.mall.dubbo.service.UserDService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.dubbo.config.annotation.Reference
;
import
org.springframework.stereotype.Component
;
@Component
@Slf4j
public
class
UserServiceClient
{
@Reference
(
version
=
"1.0.0"
,
check
=
false
)
private
UserDService
userDService
;
public
String
sayHello
(
String
param
)
{
BizResponse
<
String
>
response
=
userDService
.
sayHello
(
"hello"
);
if
(
response
.
isSuccess
())
{
return
response
.
getData
();
}
log
.
error
(
"code:{},msg:{}"
,
response
.
getCode
(),
response
.
getMsg
());
return
null
;
}
}
matrix-sample-dubbo/matrix-sample-dubbo-springboot/matrix-sample-dubbo-springboot-c/src/main/resources/application.properties
0 → 100644
View file @
0d4b21cc
server.port
=
8081
spring.application.name
=
dubbo-auto-configure-consumer-sample
dubbo.registry.address
=
zookeeper://127.0.0.1:2181
#dubbo.registry.address=nacos://127.0.0.1:8848
#
dubbo.registry.address
=
zookeeper://dev01-zk-mall1.secoolocal.com:2181?backup=dev01-zk-mall2.secoolocal.com:2181,dev01-zk-mall3.secoolocal.com:2181
\ No newline at end of file
matrix-sample-dubbo/matrix-sample-dubbo-springboot/matrix-sample-dubbo-springboot-c/src/main/resources/log4j.properties
0 → 100644
View file @
0d4b21cc
###set log levels###
log4j.rootLogger
=
info, stdout
###output to the console###
log4j.appender.stdout
=
org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target
=
System.out
log4j.appender.stdout.layout
=
org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern
=
[%d{dd/MM/yy HH:mm:ss:SSS z}] %t %5p %c{2}: %m%n
\ No newline at end of file
matrix-sample-dubbo/matrix-sample-dubbo-springboot/matrix-sample-dubbo-springboot-p/pom.xml
0 → 100644
View file @
0d4b21cc
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<parent>
<artifactId>
matrix-sample-dubbo-springboot
</artifactId>
<groupId>
com.secoo.mall
</groupId>
<version>
1.3.2.RELEASE
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
matrix-sample-dubbo-springboot-p
</artifactId>
<dependencies>
<dependency>
<groupId>
com.secoo.mall
</groupId>
<artifactId>
matrix-sample-dubbo-biz
</artifactId>
</dependency>
<dependency>
<groupId>
com.secoo.mall
</groupId>
<artifactId>
matrix-protocol-dubbo-starter
</artifactId>
</dependency>
</dependencies>
</project>
\ No newline at end of file
matrix-sample-dubbo/matrix-sample-dubbo-springboot/matrix-sample-dubbo-springboot-p/src/main/java/com/secoo/mall/dubbo/DubboProviderBootstrap.java
0 → 100644
View file @
0d4b21cc
package
com
.
secoo
.
mall
.
dubbo
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.builder.SpringApplicationBuilder
;
@SpringBootApplication
public
class
DubboProviderBootstrap
{
public
static
void
main
(
String
[]
args
)
{
new
SpringApplicationBuilder
(
DubboProviderBootstrap
.
class
)
.
run
(
args
);
}
}
\ No newline at end of file
matrix-sample-dubbo/matrix-sample-dubbo-springboot/matrix-sample-dubbo-springboot-p/src/main/java/com/secoo/mall/dubbo/provider/UserProvider.java
0 → 100644
View file @
0d4b21cc
package
com
.
secoo
.
mall
.
dubbo
.
provider
;
import
com.secoo.mall.common.core.bean.BizResponse
;
import
com.secoo.mall.common.util.response.ResponseUtil
;
import
com.secoo.mall.dubbo.dto.UserDto
;
import
com.secoo.mall.dubbo.service.UserDService
;
import
com.secoo.mall.dubbo.service.UserService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiParam
;
import
org.apache.dubbo.config.annotation.Service
;
import
javax.annotation.Resource
;
/**
* dubbo-协议使用示例
*/
@Api
(
value
=
"用户管理"
,
tags
=
"用户管理"
)
@Service
(
version
=
"1.0.0"
)
public
class
UserProvider
implements
UserDService
{
@Resource
private
UserService
service
;
/**
* 示例:
* 1.异常增强
* 2.swagger导出
*
* @param name
* @return
*/
@Override
@ApiOperation
(
value
=
"根据用户名称查询"
,
notes
=
"通过name取用户信息"
,
response
=
String
.
class
,
responseContainer
=
"List"
)
public
BizResponse
<
String
>
sayHello
(
@ApiParam
(
"姓名"
)
String
name
)
{
return
ResponseUtil
.
getSuccessBizResponse
(
service
.
sayHello
(
name
));
}
@Override
@ApiOperation
(
value
=
"根据用户Id获取信息"
,
notes
=
"根据用户Id获取信息"
,
response
=
UserDto
.
class
)
public
UserDto
getByid
(
Long
id
)
{
return
service
.
getById
(
id
);
}
}
matrix-sample-dubbo/matrix-sample-dubbo-springboot/matrix-sample-dubbo-springboot-p/src/main/resources/application.properties
0 → 100644
View file @
0d4b21cc
# Spring boot application
spring.application.name
=
dubbo-sample-springboot
##\u6307\u5B9A\u8FD0\u884C\u73AF\u5883\uFF0C\u975E\u5FC5\u586B\u3002\u6CE8\u610F\u53EA\u6709value=dev|test\uFF0C\u5E76\u4E14\u63A5\u5165\u914D\u7F6E\u4E2D\u5FC3\u6216\u8005\u8FD0\u884C\u65F6VM\u53C2\u6570\u8FFD\u52A0-Denv=dev|test,\u624D\u80FD\u751F\u6210swaager\u6587\u6863
spring.profiles.active
=
dev
# Base packages to scan Dubbo Component: @org.apache.dubbo.config.annotation.Service
#dubbo.scan.base-packages=com.secoo.demo.controller
dubbo.scan.base-packages
=
com.secoo.mall.dubbo.provider
# Dubbo Application
##dubbo\u5E94\u7528\u540D\u79F0\uFF0C\u975E\u5FC5\u586B\uFF0C\u9ED8\u8BA4\u4E3A${spring.application.name}
# dubbo.application.name=
##Dubbo Protocol
dubbo.protocol.name
=
dubbo
dubbo.protocol.port
=
12345
dubbo.registry.address
=
zookeeper://127.0.0.1:2181
##\u914D\u7F6Ezk\u96C6\u7FA4\u65B9\u5F0F
#dubbo.registry.address=zookeeper://dev01-zk-mall1.secoolocal.com:2181?backup=dev01-zk-mall2.secoolocal.com:2181,dev01-zk-mall3.secoolocal.com:2181
##\u7981\u7528\u9ED8\u8BA4ExceptionFilter\uFF0C\u542F\u7528\u81EA\u5B9A\u4E49responseExcepiton
dubbo.provider.filter
=
-exception,responseException
matrix-sample-dubbo/matrix-sample-dubbo-springboot/matrix-sample-dubbo-springboot-p/src/main/resources/log4j.properties
0 → 100644
View file @
0d4b21cc
###set log levels###
log4j.rootLogger
=
info, stdout
###output to the console###
log4j.appender.stdout
=
org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target
=
System.out
log4j.appender.stdout.layout
=
org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern
=
[%d{dd/MM/yy HH:mm:ss:SSS z}] %t %5p %c{2}: %m%n
\ No newline at end of file
matrix-sample-dubbo/matrix-sample-dubbo-springboot/pom.xml
View file @
0d4b21cc
...
@@ -10,6 +10,11 @@
...
@@ -10,6 +10,11 @@
<modelVersion>
4.0.0
</modelVersion>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
matrix-sample-dubbo-springboot
</artifactId>
<artifactId>
matrix-sample-dubbo-springboot
</artifactId>
<packaging>
pom
</packaging>
<modules>
<module>
matrix-sample-dubbo-springboot-c
</module>
<module>
matrix-sample-dubbo-springboot-p
</module>
</modules>
</project>
</project>
\ No newline at end of file
matrix-sample-dubbo/pom.xml
View file @
0d4b21cc
...
@@ -15,7 +15,22 @@
...
@@ -15,7 +15,22 @@
<module>
matrix-sample-dubbo-api
</module>
<module>
matrix-sample-dubbo-api
</module>
<module>
matrix-sample-dubbo-spring
</module>
<module>
matrix-sample-dubbo-spring
</module>
<module>
matrix-sample-dubbo-springboot
</module>
<module>
matrix-sample-dubbo-springboot
</module>
<module>
matrix-sample-dubbo-biz
</module>
</modules>
</modules>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>
com.secoo.mall
</groupId>
<artifactId>
matrix-sample-dubbo-api
</artifactId>
<version>
1.3.2.RELEASE
</version>
</dependency>
<dependency>
<groupId>
com.secoo.mall
</groupId>
<artifactId>
matrix-sample-dubbo-biz
</artifactId>
<version>
1.3.2.RELEASE
</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>
</project>
\ No newline at end of file
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