Skip to content

Commit 90b6b21

Browse files
committed
feat(SpringBoot+Netty): SpringBoot+Netty示例
Signed-off-by: yangzl <youngzil@163.com>
1 parent 5ddccd4 commit 90b6b21

File tree

46 files changed

+1834
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1834
-1
lines changed

pom.xml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313

1414
<properties>
1515
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
16+
17+
<!-- Compiler settings properties -->
18+
<maven.compiler.source>1.8</maven.compiler.source>
19+
<maven.compiler.target>1.8</maven.compiler.target>
20+
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
1621
</properties>
1722

1823
<dependencyManagement>
@@ -55,7 +60,6 @@
5560

5661
</dependencies>
5762

58-
5963
<modules>
6064
<module>quickstart-spring-boot-web</module>
6165
<module>quickstart-spring-boot-admin</module>
@@ -70,9 +74,28 @@
7074
<module>quickstart-spring-boot-druid</module>
7175
<module>quickstart-spring-boot-sqlite</module>
7276
<module>quickstart-spring-boot-jooq</module>
77+
<module>quickstart-spring-boot-netty-action</module>
7378
</modules>
7479

7580
<build>
81+
82+
<plugins>
83+
84+
<plugin>
85+
<artifactId>maven-compiler-plugin</artifactId>
86+
<version>3.8.1</version>
87+
<configuration>
88+
<source>${maven.compiler.source}</source>
89+
<target>${maven.compiler.target}</target>
90+
<compilerVersion>${maven.compiler.source}</compilerVersion>
91+
<encoding>${maven.compiler.encoding}</encoding>
92+
<showDeprecation>true</showDeprecation>
93+
<showWarnings>true</showWarnings>
94+
</configuration>
95+
</plugin>
96+
97+
</plugins>
98+
7699
<pluginManagement>
77100
<plugins>
78101
<plugin>
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# netty-action
2+
3+
[![QQ群](https://img.shields.io/badge/QQ%E7%BE%A4-787381170-yellowgreen.svg)](https://jq.qq.com/?_wv=1027&k=5HPYvQk)
4+
5+
Netty 实战相关
6+
7+
8+
## TODO LIST
9+
10+
* [x] [Netty(一) SpringBoot 整合长连接心跳机制](https://crossoverjie.top/2018/05/24/netty/Netty(1)TCP-Heartbeat/)
11+
* [x] [Netty(二) 从线程模型的角度看 Netty 为什么是高性能的?](https://crossoverjie.top/2018/07/04/netty/Netty(2)Thread-model/)
12+
* [ ] 如何解决 TCP 的拆包、粘包?
13+
14+
15+
## 安装
16+
17+
```shell
18+
git clone https://github.com/crossoverJie/netty-action.git
19+
20+
cd netty-action
21+
22+
mvn -Dmaven.test.skip=true clean package
23+
```
24+
25+
## 启动
26+
27+
```shell
28+
-- 启动 SBA
29+
java -jar springboot-admin-1.0.0-SNAPSHOT.jar
30+
31+
-- 启动 服务端
32+
java -jar netty-action-hearbeat-1.0.0-SNAPSHOT.jar
33+
34+
-- 启动 客户端
35+
java -jar netty-action-heartbeat-client-1.0.0-SNAPSHOT.jar
36+
37+
-- 启动 第二个客户端
38+
java -jar netty-action-heartbeat-client-1.0.0-SNAPSHOT.jar --server.port=8083 --spring.application.name=netty-heartbeat-client2 --logging.level.root=info --channel.id=101
39+
```
40+
41+
## 截图
42+
![show](https://github.com/crossoverJie/netty-action/blob/master/pic/show.gif)
43+
![](https://ws4.sinaimg.cn/large/006tKfTcgy1frqfwembi6j31kw0o0dot.jpg)
44+
45+
46+
# 联系作者
47+
- [crossoverJie@gmail.com](mailto:crossoverJie@gmail.com)
48+
- 微信公众号
49+
50+
![](https://ws1.sinaimg.cn/large/006tKfTcly1ftmfdo6mhmj30760760t7.jpg)
51+
30 MB
Loading
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
<?xml version="1.0"?>
2+
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
4+
5+
<parent>
6+
<groupId>org.quickstart</groupId>
7+
<artifactId>quickstart-spring-boot</artifactId>
8+
<version>0.0.1-SNAPSHOT</version>
9+
</parent>
10+
11+
<modelVersion>4.0.0</modelVersion>
12+
<artifactId>quickstart-spring-boot-netty-action</artifactId>
13+
<packaging>pom</packaging>
14+
<name>${project.artifactId}-${project.version}</name>
15+
<url>http://maven.apache.org</url>
16+
<description>Demo project for ${project.artifactId}</description>
17+
18+
19+
<properties>
20+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
21+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
22+
<netty.version>4.1.52.Final</netty.version>
23+
<swagger.version>2.10.5</swagger.version>
24+
<junit.version>4.13</junit.version>
25+
<spring-boot-admin.version>1.5.7</spring-boot-admin.version>
26+
</properties>
27+
28+
<modules>
29+
<module>quickstart-spring-boot-netty-action-common</module>
30+
<module>quickstart-spring-boot-netty-action-heartbeat</module>
31+
<module>quickstart-spring-boot-netty-action-heartbeat-client</module>
32+
<module>quickstart-spring-boot-netty-action-springboot-admin</module>
33+
</modules>
34+
35+
36+
<dependencyManagement>
37+
<dependencies>
38+
39+
<dependency>
40+
<groupId>io.springfox</groupId>
41+
<artifactId>springfox-swagger2</artifactId>
42+
<version>${swagger.version}</version>
43+
<scope>compile</scope>
44+
</dependency>
45+
<dependency>
46+
<groupId>io.springfox</groupId>
47+
<artifactId>springfox-swagger-ui</artifactId>
48+
<version>${swagger.version}</version>
49+
</dependency>
50+
51+
<dependency>
52+
<groupId>io.netty</groupId>
53+
<artifactId>netty-all</artifactId>
54+
<version>${netty.version}</version>
55+
</dependency>
56+
57+
<dependency>
58+
<groupId>junit</groupId>
59+
<artifactId>junit</artifactId>
60+
<version>${junit.version}</version>
61+
</dependency>
62+
63+
<dependency>
64+
<groupId>com.alibaba</groupId>
65+
<artifactId>fastjson</artifactId>
66+
<version>1.2.73</version>
67+
</dependency>
68+
69+
<dependency>
70+
<groupId>com.google.guava</groupId>
71+
<artifactId>guava</artifactId>
72+
<version>29.0-jre</version>
73+
</dependency>
74+
75+
<dependency>
76+
<groupId>de.codecentric</groupId>
77+
<artifactId>spring-boot-admin-starter-client</artifactId>
78+
<version>${spring-boot-admin.version}</version>
79+
</dependency>
80+
<dependency>
81+
<groupId>de.codecentric</groupId>
82+
<artifactId>spring-boot-admin-starter-server</artifactId>
83+
<version>${spring-boot-admin.version}</version>
84+
</dependency>
85+
<dependency>
86+
<groupId>de.codecentric</groupId>
87+
<artifactId>spring-boot-admin-server-ui</artifactId>
88+
<version>${spring-boot-admin.version}</version>
89+
</dependency>
90+
91+
</dependencies>
92+
</dependencyManagement>
93+
94+
</project>
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<?xml version="1.0"?>
2+
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
4+
5+
<parent>
6+
<groupId>org.quickstart</groupId>
7+
<artifactId>quickstart-spring-boot-netty-action</artifactId>
8+
<version>0.0.1-SNAPSHOT</version>
9+
</parent>
10+
11+
<modelVersion>4.0.0</modelVersion>
12+
<artifactId>quickstart-spring-boot-netty-action-common</artifactId>
13+
<packaging>jar</packaging>
14+
<name>${project.artifactId}-${project.version}</name>
15+
<url>http://maven.apache.org</url>
16+
<description>Demo project for ${project.artifactId}</description>
17+
18+
<dependencies>
19+
20+
<dependency>
21+
<groupId>org.springframework.boot</groupId>
22+
<artifactId>spring-boot-configuration-processor</artifactId>
23+
<optional>true</optional>
24+
</dependency>
25+
26+
<dependency>
27+
<groupId>org.springframework.boot</groupId>
28+
<artifactId>spring-boot-starter-actuator</artifactId>
29+
</dependency>
30+
31+
<dependency>
32+
<groupId>de.codecentric</groupId>
33+
<artifactId>spring-boot-admin-starter-client</artifactId>
34+
</dependency>
35+
36+
<dependency>
37+
<groupId>io.springfox</groupId>
38+
<artifactId>springfox-swagger2</artifactId>
39+
<scope>compile</scope>
40+
</dependency>
41+
<dependency>
42+
<groupId>io.springfox</groupId>
43+
<artifactId>springfox-swagger-ui</artifactId>
44+
</dependency>
45+
46+
<dependency>
47+
<groupId>io.netty</groupId>
48+
<artifactId>netty-all</artifactId>
49+
<version>${netty.version}</version>
50+
</dependency>
51+
52+
<dependency>
53+
<groupId>com.alibaba</groupId>
54+
<artifactId>fastjson</artifactId>
55+
</dependency>
56+
57+
<dependency>
58+
<groupId>com.google.guava</groupId>
59+
<artifactId>guava</artifactId>
60+
</dependency>
61+
62+
<dependency>
63+
<groupId>ch.qos.logback</groupId>
64+
<artifactId>logback-classic</artifactId>
65+
</dependency>
66+
67+
<dependency>
68+
<groupId>junit</groupId>
69+
<artifactId>junit</artifactId>
70+
</dependency>
71+
72+
</dependencies>
73+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package org.quickstart.spring.boot.netty.action.common.constant;
2+
3+
/**
4+
* Function:常量
5+
*
6+
* @author crossoverJie
7+
* Date: 28/03/2018 17:41
8+
* @since JDK 1.8
9+
*/
10+
public class Constants {
11+
12+
13+
/**
14+
* 服务端手动 push 次数
15+
*/
16+
public static final String COUNTER_SERVER_PUSH_COUNT = "counter.server.push.count" ;
17+
18+
19+
/**
20+
* 客户端手动 push 次数
21+
*/
22+
public static final String COUNTER_CLIENT_PUSH_COUNT = "counter.client.push.count" ;
23+
24+
25+
}

0 commit comments

Comments
 (0)