diff --git a/api-boot-project/api-boot-autoconfigure/pom.xml b/api-boot-project/api-boot-autoconfigure/pom.xml
index 7f52bcb2..e065ef1f 100644
--- a/api-boot-project/api-boot-autoconfigure/pom.xml
+++ b/api-boot-project/api-boot-autoconfigure/pom.xml
@@ -161,6 +161,21 @@
minbox-oss
true
+
+ org.minbox.framework
+ message-pipe-client
+ true
+
+
+ org.minbox.framework
+ message-pipe-server
+ true
+
+
+ org.minbox.framework
+ message-pipe-spring-context
+ true
+
diff --git a/api-boot-project/api-boot-autoconfigure/src/main/java/org/minbox/framework/api/boot/autoconfigure/message/pipe/client/MessagePipeClientAutoConfiguration.java b/api-boot-project/api-boot-autoconfigure/src/main/java/org/minbox/framework/api/boot/autoconfigure/message/pipe/client/MessagePipeClientAutoConfiguration.java
new file mode 100644
index 00000000..78c9689d
--- /dev/null
+++ b/api-boot-project/api-boot-autoconfigure/src/main/java/org/minbox/framework/api/boot/autoconfigure/message/pipe/client/MessagePipeClientAutoConfiguration.java
@@ -0,0 +1,34 @@
+package org.minbox.framework.api.boot.autoconfigure.message.pipe.client;
+
+import org.minbox.framework.message.pipe.client.config.ClientConfiguration;
+import org.minbox.framework.message.pipe.spring.annotation.client.EnableMessagePipeClient;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.context.annotation.Bean;
+
+/**
+ * The Message Pipe configuration
+ *
+ * @author 恒宇少年
+ */
+@ConditionalOnClass(ClientConfiguration.class)
+@EnableConfigurationProperties(MessagePipeClientProperties.class)
+@EnableMessagePipeClient
+public class MessagePipeClientAutoConfiguration {
+ private MessagePipeClientProperties messagePipeClientProperties;
+
+ public MessagePipeClientAutoConfiguration(MessagePipeClientProperties messagePipeClientProperties) {
+ this.messagePipeClientProperties = messagePipeClientProperties;
+ }
+
+ /**
+ * Create {@link ClientConfiguration} instance
+ *
+ * @return The {@link ClientConfiguration} instance
+ * @see MessagePipeClientProperties#getConfiguration
+ */
+ @Bean
+ public ClientConfiguration clientConfiguration() {
+ return messagePipeClientProperties.getConfiguration();
+ }
+}
diff --git a/api-boot-project/api-boot-autoconfigure/src/main/java/org/minbox/framework/api/boot/autoconfigure/message/pipe/client/MessagePipeClientProperties.java b/api-boot-project/api-boot-autoconfigure/src/main/java/org/minbox/framework/api/boot/autoconfigure/message/pipe/client/MessagePipeClientProperties.java
new file mode 100644
index 00000000..0303e23a
--- /dev/null
+++ b/api-boot-project/api-boot-autoconfigure/src/main/java/org/minbox/framework/api/boot/autoconfigure/message/pipe/client/MessagePipeClientProperties.java
@@ -0,0 +1,27 @@
+package org.minbox.framework.api.boot.autoconfigure.message.pipe.client;
+
+import lombok.Data;
+import org.minbox.framework.message.pipe.client.config.ClientConfiguration;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.boot.context.properties.NestedConfigurationProperty;
+
+import static org.minbox.framework.api.boot.autoconfigure.message.pipe.client.MessagePipeClientProperties.MESSAGE_PIPE_PREFIX;
+
+/**
+ * The Message Pipe client config properties
+ *
+ * @author 恒宇少年
+ */
+@ConfigurationProperties(prefix = MESSAGE_PIPE_PREFIX)
+@Data
+public class MessagePipeClientProperties {
+ /**
+ * The config prefix for "message-pipe-client"
+ */
+ public static final String MESSAGE_PIPE_PREFIX = "api.boot.message.pipe.client";
+ /**
+ * The {@link ClientConfiguration} client configuration
+ */
+ @NestedConfigurationProperty
+ private ClientConfiguration configuration = new ClientConfiguration();
+}
diff --git a/api-boot-project/api-boot-autoconfigure/src/main/java/org/minbox/framework/api/boot/autoconfigure/message/pipe/server/MessagePipeServerAutoConfiguration.java b/api-boot-project/api-boot-autoconfigure/src/main/java/org/minbox/framework/api/boot/autoconfigure/message/pipe/server/MessagePipeServerAutoConfiguration.java
new file mode 100644
index 00000000..739e33c4
--- /dev/null
+++ b/api-boot-project/api-boot-autoconfigure/src/main/java/org/minbox/framework/api/boot/autoconfigure/message/pipe/server/MessagePipeServerAutoConfiguration.java
@@ -0,0 +1,54 @@
+package org.minbox.framework.api.boot.autoconfigure.message.pipe.server;
+
+import org.minbox.framework.message.pipe.server.config.MessagePipeConfiguration;
+import org.minbox.framework.message.pipe.server.config.ServerConfiguration;
+import org.minbox.framework.message.pipe.spring.annotation.server.EnableMessagePipeServer;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.context.annotation.Bean;
+
+/**
+ * The Message Pipe Server configuration
+ *
+ * @author 恒宇少年
+ */
+@ConditionalOnClass(ServerConfiguration.class)
+@EnableConfigurationProperties(MessagePipeServerProperties.class)
+@EnableMessagePipeServer
+public class MessagePipeServerAutoConfiguration {
+ private MessagePipeServerProperties messagePipeServerProperties;
+
+ public MessagePipeServerAutoConfiguration(MessagePipeServerProperties messagePipeServerProperties) {
+ this.messagePipeServerProperties = messagePipeServerProperties;
+ }
+
+ /**
+ * Create {@link ServerConfiguration} instance
+ *
+ * @return The {@link ServerConfiguration} instance
+ * @see MessagePipeServerProperties#getConfiguration
+ */
+ @Bean
+ public ServerConfiguration serverConfiguration() {
+ return messagePipeServerProperties.getConfiguration();
+ }
+
+ /**
+ * Create {@link MessagePipeConfiguration}
+ *
+ * The common configuration instance for each channel
+ *
+ * @return The {@link MessagePipeConfiguration} instance
+ */
+ @Bean
+ public MessagePipeConfiguration messagePipeConfiguration() {
+ MessagePipeConfiguration configuration = MessagePipeConfiguration.defaultConfiguration();
+ MessagePipeConfiguration.LockTime lockTime =
+ new MessagePipeConfiguration.LockTime()
+ .setLeaseTime(messagePipeServerProperties.getLockLeaseTime())
+ .setTimeUnit(messagePipeServerProperties.getLockLeaseTimeUnit());
+ configuration.setLockTime(lockTime);
+ configuration.setDistributionMessagePoolSize(messagePipeServerProperties.getDistributionMessagePoolSize());
+ return configuration;
+ }
+}
diff --git a/api-boot-project/api-boot-autoconfigure/src/main/java/org/minbox/framework/api/boot/autoconfigure/message/pipe/server/MessagePipeServerProperties.java b/api-boot-project/api-boot-autoconfigure/src/main/java/org/minbox/framework/api/boot/autoconfigure/message/pipe/server/MessagePipeServerProperties.java
new file mode 100644
index 00000000..0567a704
--- /dev/null
+++ b/api-boot-project/api-boot-autoconfigure/src/main/java/org/minbox/framework/api/boot/autoconfigure/message/pipe/server/MessagePipeServerProperties.java
@@ -0,0 +1,41 @@
+package org.minbox.framework.api.boot.autoconfigure.message.pipe.server;
+
+import lombok.Data;
+import org.minbox.framework.message.pipe.server.config.ServerConfiguration;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.boot.context.properties.NestedConfigurationProperty;
+
+import java.util.concurrent.TimeUnit;
+
+import static org.minbox.framework.api.boot.autoconfigure.message.pipe.server.MessagePipeServerProperties.MESSAGE_PIPE_PREFIX;
+
+/**
+ * The Message Pipe server config properties
+ *
+ * @author 恒宇少年
+ */
+@ConfigurationProperties(prefix = MESSAGE_PIPE_PREFIX)
+@Data
+public class MessagePipeServerProperties {
+ /**
+ * The config prefix for "message-pipe-server"
+ */
+ public static final String MESSAGE_PIPE_PREFIX = "api.boot.message.pipe.server";
+ /**
+ * The {@link ServerConfiguration} server configuration
+ */
+ @NestedConfigurationProperty
+ private ServerConfiguration configuration = new ServerConfiguration();
+ /**
+ * The redisson lock lease time
+ */
+ private long lockLeaseTime = 10;
+ /**
+ * The redisson lock lean {@link TimeUnit}
+ */
+ private TimeUnit lockLeaseTimeUnit = TimeUnit.SECONDS;
+ /**
+ * The number of threads in the message thread pool
+ */
+ private int distributionMessagePoolSize = 10;
+}
diff --git a/api-boot-project/api-boot-autoconfigure/src/main/resources/META-INF/spring.factories b/api-boot-project/api-boot-autoconfigure/src/main/resources/META-INF/spring.factories
index d2fe528c..e1ae8a8a 100644
--- a/api-boot-project/api-boot-autoconfigure/src/main/resources/META-INF/spring.factories
+++ b/api-boot-project/api-boot-autoconfigure/src/main/resources/META-INF/spring.factories
@@ -22,4 +22,6 @@ org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
org.minbox.framework.api.boot.autoconfigure.logging.admin.ApiBootLoggingAdminSecurityAutoConfiguration,\
org.minbox.framework.api.boot.autoconfigure.sequence.ApiBootSequenceAutoConfiguration,\
org.minbox.framework.api.boot.autoconfigure.mongo.ApiBootMongoClientSettingsAutoConfiguration,\
- org.minbox.framework.api.boot.autoconfigure.tools.ApiBootToolsAutoConfiguration
+ org.minbox.framework.api.boot.autoconfigure.tools.ApiBootToolsAutoConfiguration,\
+ org.minbox.framework.api.boot.autoconfigure.message.pipe.client.MessagePipeClientAutoConfiguration,\
+ org.minbox.framework.api.boot.autoconfigure.message.pipe.server.MessagePipeServerAutoConfiguration
diff --git a/api-boot-project/api-boot-common/src/main/java/org/minbox/framework/api/boot/common/tools/ClassTools.java b/api-boot-project/api-boot-common/src/main/java/org/minbox/framework/api/boot/common/tools/ClassTools.java
index 1495469f..f9dfdd30 100644
--- a/api-boot-project/api-boot-common/src/main/java/org/minbox/framework/api/boot/common/tools/ClassTools.java
+++ b/api-boot-project/api-boot-common/src/main/java/org/minbox/framework/api/boot/common/tools/ClassTools.java
@@ -55,6 +55,7 @@ static Reflections initReflections(String scannerPackage) {
* 获取指定package下的接口实现类
*
* @param scannerPackage 扫描的package
+ * @param clazz The class type
* @return 实现类集合
*/
public static Collection> getSubClassList(String scannerPackage, Class clazz) {
diff --git a/api-boot-project/api-boot-common/src/main/java/org/minbox/framework/api/boot/common/tools/ListTools.java b/api-boot-project/api-boot-common/src/main/java/org/minbox/framework/api/boot/common/tools/ListTools.java
index 2e189e57..001712ac 100644
--- a/api-boot-project/api-boot-common/src/main/java/org/minbox/framework/api/boot/common/tools/ListTools.java
+++ b/api-boot-project/api-boot-common/src/main/java/org/minbox/framework/api/boot/common/tools/ListTools.java
@@ -35,8 +35,8 @@ public class ListTools {
/**
* value converter to list
*
- * @param value
- * @return
+ * @param value The object value
+ * @return list collection
*/
public static List convertToList(Object value) {
List resourceUrls = new ArrayList<>();
diff --git a/api-boot-project/api-boot-dependencies/pom.xml b/api-boot-project/api-boot-dependencies/pom.xml
index 76a19307..91a214ac 100644
--- a/api-boot-project/api-boot-dependencies/pom.xml
+++ b/api-boot-project/api-boot-dependencies/pom.xml
@@ -16,12 +16,13 @@
${basedir}/../..
- 5.2.7.RELEASE
+ 5.2.8.RELEASE
2.3.3.RELEASE
- 1.0.1-SNAPSHOT
+ 1.0.1.RELEASE
1.0.5.RELEASE
+ 1.0.0.RELEASE
1.1.21
@@ -56,6 +57,14 @@
import
pom
+
+ org.minbox.framework
+ message-pipe-bom
+ ${message-pipe.version}
+ import
+ pom
+
+
com.alibaba
@@ -190,6 +199,16 @@
api-boot-starter-mongo-client-settings
${project.version}
+
+ org.minbox.framework
+ api-boot-starter-message-pipe-client
+ ${project.version}
+
+
+ org.minbox.framework
+ api-boot-starter-message-pipe-server
+ ${project.version}
+
diff --git a/api-boot-project/api-boot-starters/api-boot-starter-message-pipe-client/pom.xml b/api-boot-project/api-boot-starters/api-boot-starter-message-pipe-client/pom.xml
new file mode 100644
index 00000000..c6368aee
--- /dev/null
+++ b/api-boot-project/api-boot-starters/api-boot-starter-message-pipe-client/pom.xml
@@ -0,0 +1,39 @@
+
+
+
+ api-boot-starters
+ org.minbox.framework
+ ${revision}
+
+ 4.0.0
+ jar
+ api-boot-starter-message-pipe-client
+
+ ${basedir}/../../..
+
+
+
+ org.minbox.framework
+ api-boot-starter
+
+
+ org.minbox.framework
+ message-pipe-client
+
+
+ org.minbox.framework
+ message-pipe-spring-context
+
+
+
+
+ 恒宇少年
+ jnyuqy@gmail.com
+ minbox-projects
+ https://gitee.com/minbox-projects
+
+
+
+
diff --git a/api-boot-project/api-boot-starters/api-boot-starter-message-pipe-server/pom.xml b/api-boot-project/api-boot-starters/api-boot-starter-message-pipe-server/pom.xml
new file mode 100644
index 00000000..61759f05
--- /dev/null
+++ b/api-boot-project/api-boot-starters/api-boot-starter-message-pipe-server/pom.xml
@@ -0,0 +1,38 @@
+
+
+
+ api-boot-starters
+ org.minbox.framework
+ ${revision}
+
+ 4.0.0
+ jar
+ api-boot-starter-message-pipe-server
+
+ ${basedir}/../../..
+
+
+
+ org.minbox.framework
+ api-boot-starter
+
+
+ org.minbox.framework
+ message-pipe-server
+
+
+ org.minbox.framework
+ message-pipe-spring-context
+
+
+
+
+ 恒宇少年
+ jnyuqy@gmail.com
+ minbox-projects
+ https://gitee.com/minbox-projects
+
+
+
diff --git a/api-boot-project/api-boot-starters/pom.xml b/api-boot-project/api-boot-starters/pom.xml
index 6bb7eaa0..19d6c54f 100644
--- a/api-boot-project/api-boot-starters/pom.xml
+++ b/api-boot-project/api-boot-starters/pom.xml
@@ -33,6 +33,8 @@
api-boot-starter-logging-admin
api-boot-starter-sequence
api-boot-starter-mongo-client-settings
+ api-boot-starter-message-pipe-client
+ api-boot-starter-message-pipe-server
diff --git a/api-boot-samples/api-boot-sample-message-pipe-client/pom.xml b/api-boot-samples/api-boot-sample-message-pipe-client/pom.xml
new file mode 100644
index 00000000..33a62a07
--- /dev/null
+++ b/api-boot-samples/api-boot-sample-message-pipe-client/pom.xml
@@ -0,0 +1,40 @@
+
+
+
+ api-boot-samples
+ org.minbox.framework
+ ${revision}
+
+ 4.0.0
+ jar
+ api-boot-sample-message-pipe-client
+
+
+ org.springframework.boot
+ spring-boot-starter-data-redis
+
+
+ org.redisson
+ redisson-spring-boot-starter
+ 3.13.3
+
+
+ org.minbox.framework
+ api-boot-starter-message-pipe-client
+
+
+
+
+
+
+ org.minbox.framework
+ api-boot-dependencies
+ ${api-boot.version}
+ import
+ pom
+
+
+
+
diff --git a/api-boot-samples/api-boot-sample-message-pipe-client/src/main/java/org/minbox/framework/api/boot/sample/message/pipe/client/MessagePipeClientSampleApplication.java b/api-boot-samples/api-boot-sample-message-pipe-client/src/main/java/org/minbox/framework/api/boot/sample/message/pipe/client/MessagePipeClientSampleApplication.java
new file mode 100644
index 00000000..e3bffb56
--- /dev/null
+++ b/api-boot-samples/api-boot-sample-message-pipe-client/src/main/java/org/minbox/framework/api/boot/sample/message/pipe/client/MessagePipeClientSampleApplication.java
@@ -0,0 +1,22 @@
+package org.minbox.framework.api.boot.sample.message.pipe.client;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+/**
+ * @author 恒宇少年
+ */
+@SpringBootApplication
+public class MessagePipeClientSampleApplication {
+ /**
+ * logger instance
+ */
+ static Logger logger = LoggerFactory.getLogger(MessagePipeClientSampleApplication.class);
+
+ public static void main(String[] args) {
+ SpringApplication.run(MessagePipeClientSampleApplication.class, args);
+ logger.info("ApiBoot Message Pipe Client 服务启动成功.");
+ }
+}
diff --git a/api-boot-samples/api-boot-sample-message-pipe-client/src/main/java/org/minbox/framework/api/boot/sample/message/pipe/client/processor/TestMessageProcessor.java b/api-boot-samples/api-boot-sample-message-pipe-client/src/main/java/org/minbox/framework/api/boot/sample/message/pipe/client/processor/TestMessageProcessor.java
new file mode 100644
index 00000000..4cd7f6e0
--- /dev/null
+++ b/api-boot-samples/api-boot-sample-message-pipe-client/src/main/java/org/minbox/framework/api/boot/sample/message/pipe/client/processor/TestMessageProcessor.java
@@ -0,0 +1,27 @@
+package org.minbox.framework.api.boot.sample.message.pipe.client.processor;
+
+import lombok.extern.slf4j.Slf4j;
+import org.minbox.framework.message.pipe.client.process.MessageProcessor;
+import org.springframework.stereotype.Service;
+
+/**
+ * 示例 {@link MessageProcessor}
+ *
+ * @author 恒宇少年
+ */
+@Slf4j
+@Service
+public class TestMessageProcessor implements MessageProcessor {
+ private static final String TEST_PIPE_NAME = "test";
+
+ @Override
+ public String bindingPipeName() {
+ return TEST_PIPE_NAME;
+ }
+
+ @Override
+ public boolean processing(String requestId, byte[] messageBody) {
+ log.info("消费消息:{},内容:{}", requestId, new String(messageBody));
+ return true;
+ }
+}
diff --git a/api-boot-samples/api-boot-sample-message-pipe-client/src/main/resources/application.yml b/api-boot-samples/api-boot-sample-message-pipe-client/src/main/resources/application.yml
new file mode 100644
index 00000000..40cf7cd9
--- /dev/null
+++ b/api-boot-samples/api-boot-sample-message-pipe-client/src/main/resources/application.yml
@@ -0,0 +1,23 @@
+spring:
+ redis:
+ port: 6379
+ timeout: 10000
+ database: 1
+ lettuce:
+ pool:
+ max-active: 200
+ max-idle: 200
+server:
+ port: 8082
+api:
+ boot:
+ message:
+ pipe:
+ client:
+ configuration:
+ # Server地址,默认为 "localhost"
+ server-address: localhost
+ # Server端口号,默认为 "5200"
+ server-port: 5200
+ # 本地Client端口号,默认为 "5201"
+ local-port: 5201
diff --git a/api-boot-samples/api-boot-sample-message-pipe-server/pom.xml b/api-boot-samples/api-boot-sample-message-pipe-server/pom.xml
new file mode 100644
index 00000000..d52467dd
--- /dev/null
+++ b/api-boot-samples/api-boot-sample-message-pipe-server/pom.xml
@@ -0,0 +1,40 @@
+
+
+
+ api-boot-samples
+ org.minbox.framework
+ ${revision}
+
+ 4.0.0
+ jar
+ api-boot-sample-message-pipe-server
+
+
+ org.springframework.boot
+ spring-boot-starter-data-redis
+
+
+ org.redisson
+ redisson-spring-boot-starter
+ 3.13.3
+
+
+ org.minbox.framework
+ api-boot-starter-message-pipe-server
+
+
+
+
+
+
+ org.minbox.framework
+ api-boot-dependencies
+ ${api-boot.version}
+ import
+ pom
+
+
+
+
diff --git a/api-boot-samples/api-boot-sample-message-pipe-server/src/main/java/org/minbox/framework/api/boot/sample/message/pipe/server/MessagePipeServerSampleApplication.java b/api-boot-samples/api-boot-sample-message-pipe-server/src/main/java/org/minbox/framework/api/boot/sample/message/pipe/server/MessagePipeServerSampleApplication.java
new file mode 100644
index 00000000..7462721d
--- /dev/null
+++ b/api-boot-samples/api-boot-sample-message-pipe-server/src/main/java/org/minbox/framework/api/boot/sample/message/pipe/server/MessagePipeServerSampleApplication.java
@@ -0,0 +1,22 @@
+package org.minbox.framework.api.boot.sample.message.pipe.server;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+/**
+ * @author 恒宇少年
+ */
+@SpringBootApplication
+public class MessagePipeServerSampleApplication {
+ /**
+ * logger instance
+ */
+ static Logger logger = LoggerFactory.getLogger(MessagePipeServerSampleApplication.class);
+
+ public static void main(String[] args) {
+ SpringApplication.run(MessagePipeServerSampleApplication.class, args);
+ logger.info("ApiBoot Message Pipe Server服务启动成功.");
+ }
+}
diff --git a/api-boot-samples/api-boot-sample-message-pipe-server/src/main/resources/application.yml b/api-boot-samples/api-boot-sample-message-pipe-server/src/main/resources/application.yml
new file mode 100644
index 00000000..6c3ade7f
--- /dev/null
+++ b/api-boot-samples/api-boot-sample-message-pipe-server/src/main/resources/application.yml
@@ -0,0 +1,20 @@
+spring:
+ redis:
+ port: 6379
+ timeout: 10000
+ database: 1
+ lettuce:
+ pool:
+ max-active: 200
+ max-idle: 200
+server:
+ port: 8081
+
+api:
+ boot:
+ message:
+ pipe:
+ server:
+ configuration:
+ # 配置监听端口号,默认为5200
+ server-port: 5200
diff --git a/api-boot-samples/pom.xml b/api-boot-samples/pom.xml
index 40c0cef2..929fe2a2 100644
--- a/api-boot-samples/pom.xml
+++ b/api-boot-samples/pom.xml
@@ -43,5 +43,7 @@
api-boot-sample-sequence
api-boot-sample-mongo-client-settings
api-boot-sample-tools
+ api-boot-sample-message-pipe-client
+ api-boot-sample-message-pipe-server