Skip to content

Commit c8d55ca

Browse files
committed
✅ Add "message-pipe" usage example
1 parent 5dbe8a4 commit c8d55ca

File tree

8 files changed

+196
-0
lines changed

8 files changed

+196
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<parent>
6+
<artifactId>api-boot-samples</artifactId>
7+
<groupId>org.minbox.framework</groupId>
8+
<version>${revision}</version>
9+
</parent>
10+
<modelVersion>4.0.0</modelVersion>
11+
<packaging>jar</packaging>
12+
<artifactId>api-boot-sample-message-pipe-client</artifactId>
13+
<dependencies>
14+
<dependency>
15+
<groupId>org.springframework.boot</groupId>
16+
<artifactId>spring-boot-starter-data-redis</artifactId>
17+
</dependency>
18+
<dependency>
19+
<groupId>org.redisson</groupId>
20+
<artifactId>redisson-spring-boot-starter</artifactId>
21+
<version>3.13.3</version>
22+
</dependency>
23+
<dependency>
24+
<groupId>org.minbox.framework</groupId>
25+
<artifactId>api-boot-starter-message-pipe-client</artifactId>
26+
</dependency>
27+
</dependencies>
28+
<dependencyManagement>
29+
<dependencies>
30+
<!--ApiBoot 版本依赖-->
31+
<dependency>
32+
<groupId>org.minbox.framework</groupId>
33+
<artifactId>api-boot-dependencies</artifactId>
34+
<version>${api-boot.version}</version>
35+
<scope>import</scope>
36+
<type>pom</type>
37+
</dependency>
38+
</dependencies>
39+
</dependencyManagement>
40+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package org.minbox.framework.api.boot.sample.message.pipe.client;
2+
3+
import org.slf4j.Logger;
4+
import org.slf4j.LoggerFactory;
5+
import org.springframework.boot.SpringApplication;
6+
import org.springframework.boot.autoconfigure.SpringBootApplication;
7+
8+
/**
9+
* @author 恒宇少年
10+
*/
11+
@SpringBootApplication
12+
public class MessagePipeClientSampleApplication {
13+
/**
14+
* logger instance
15+
*/
16+
static Logger logger = LoggerFactory.getLogger(MessagePipeClientSampleApplication.class);
17+
18+
public static void main(String[] args) {
19+
SpringApplication.run(MessagePipeClientSampleApplication.class, args);
20+
logger.info("ApiBoot Message Pipe Client 服务启动成功.");
21+
}
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package org.minbox.framework.api.boot.sample.message.pipe.client.processor;
2+
3+
import lombok.extern.slf4j.Slf4j;
4+
import org.minbox.framework.message.pipe.client.process.MessageProcessor;
5+
import org.springframework.stereotype.Service;
6+
7+
/**
8+
* 示例 {@link MessageProcessor}
9+
*
10+
* @author 恒宇少年
11+
*/
12+
@Slf4j
13+
@Service
14+
public class TestMessageProcessor implements MessageProcessor {
15+
private static final String TEST_PIPE_NAME = "test";
16+
17+
@Override
18+
public String bindingPipeName() {
19+
return TEST_PIPE_NAME;
20+
}
21+
22+
@Override
23+
public boolean processing(String requestId, byte[] messageBody) {
24+
log.info("消费消息:{},内容:{}", requestId, new String(messageBody));
25+
return true;
26+
}
27+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
spring:
2+
redis:
3+
port: 6379
4+
timeout: 10000
5+
database: 1
6+
lettuce:
7+
pool:
8+
max-active: 200
9+
max-idle: 200
10+
server:
11+
port: 8082
12+
api:
13+
boot:
14+
message:
15+
pipe:
16+
client:
17+
configuration:
18+
# Server地址,默认为 "localhost"
19+
server-address: localhost
20+
# Server端口号,默认为 "5200"
21+
server-port: 5200
22+
# 本地Client端口号,默认为 "5201"
23+
local-port: 5201
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<parent>
6+
<artifactId>api-boot-samples</artifactId>
7+
<groupId>org.minbox.framework</groupId>
8+
<version>${revision}</version>
9+
</parent>
10+
<modelVersion>4.0.0</modelVersion>
11+
<packaging>jar</packaging>
12+
<artifactId>api-boot-sample-message-pipe-server</artifactId>
13+
<dependencies>
14+
<dependency>
15+
<groupId>org.springframework.boot</groupId>
16+
<artifactId>spring-boot-starter-data-redis</artifactId>
17+
</dependency>
18+
<dependency>
19+
<groupId>org.redisson</groupId>
20+
<artifactId>redisson-spring-boot-starter</artifactId>
21+
<version>3.13.3</version>
22+
</dependency>
23+
<dependency>
24+
<groupId>org.minbox.framework</groupId>
25+
<artifactId>api-boot-starter-message-pipe-server</artifactId>
26+
</dependency>
27+
</dependencies>
28+
<dependencyManagement>
29+
<dependencies>
30+
<!--ApiBoot 版本依赖-->
31+
<dependency>
32+
<groupId>org.minbox.framework</groupId>
33+
<artifactId>api-boot-dependencies</artifactId>
34+
<version>${api-boot.version}</version>
35+
<scope>import</scope>
36+
<type>pom</type>
37+
</dependency>
38+
</dependencies>
39+
</dependencyManagement>
40+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package org.minbox.framework.api.boot.sample.message.pipe.server;
2+
3+
import org.slf4j.Logger;
4+
import org.slf4j.LoggerFactory;
5+
import org.springframework.boot.SpringApplication;
6+
import org.springframework.boot.autoconfigure.SpringBootApplication;
7+
8+
/**
9+
* @author 恒宇少年
10+
*/
11+
@SpringBootApplication
12+
public class MessagePipeServerSampleApplication {
13+
/**
14+
* logger instance
15+
*/
16+
static Logger logger = LoggerFactory.getLogger(MessagePipeServerSampleApplication.class);
17+
18+
public static void main(String[] args) {
19+
SpringApplication.run(MessagePipeServerSampleApplication.class, args);
20+
logger.info("ApiBoot Message Pipe Server服务启动成功.");
21+
}
22+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
spring:
2+
redis:
3+
port: 6379
4+
timeout: 10000
5+
database: 1
6+
lettuce:
7+
pool:
8+
max-active: 200
9+
max-idle: 200
10+
server:
11+
port: 8081
12+
13+
api:
14+
boot:
15+
message:
16+
pipe:
17+
server:
18+
configuration:
19+
# 配置监听端口号,默认为5200
20+
server-port: 5200

api-boot-samples/pom.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,7 @@
4343
<module>api-boot-sample-sequence</module>
4444
<module>api-boot-sample-mongo-client-settings</module>
4545
<module>api-boot-sample-tools</module>
46+
<module>api-boot-sample-message-pipe-client</module>
47+
<module>api-boot-sample-message-pipe-server</module>
4648
</modules>
4749
</project>

0 commit comments

Comments
 (0)