Skip to content

Commit c85848f

Browse files
committed
Merge branch '2.3.x'
2 parents 454c6fd + d010c6c commit c85848f

File tree

10 files changed

+196
-63
lines changed

10 files changed

+196
-63
lines changed

api-boot-project/api-boot-dependencies/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<!--Minbox Projects-->
2323
<minbox-bom.version>1.0.1.RELEASE</minbox-bom.version>
2424
<code.builder.core.version>1.0.5.RELEASE</code.builder.core.version>
25-
<message-pipe-bom.version>1.0.2.RELEASE</message-pipe-bom.version>
25+
<message-pipe-bom.version>1.0.3-SNAPSHOT</message-pipe-bom.version>
2626

2727
<!--Others-->
2828
<druid.starter.version>1.1.21</druid.starter.version>

api-boot-samples/api-boot-sample-integration/pom.xml

Lines changed: 39 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -129,43 +129,52 @@
129129
<version>4.5.1</version>
130130
</dependency>
131131
</dependencies>
132+
<profiles>
133+
<profile>
134+
<id>codegen</id>
135+
<build>
136+
<plugins>
137+
<plugin>
138+
<groupId>org.minbox.framework</groupId>
139+
<artifactId>api-boot-mybatis-enhance-maven-codegen</artifactId>
140+
<version>${api-boot.version}</version>
141+
<dependencies>
142+
<!--数据驱动依赖-->
143+
<dependency>
144+
<groupId>mysql</groupId>
145+
<artifactId>mysql-connector-java</artifactId>
146+
<version>5.1.47</version>
147+
</dependency>
148+
</dependencies>
149+
<executions>
150+
<execution>
151+
<goals>
152+
<goal>generator</goal>
153+
</goals>
154+
</execution>
155+
</executions>
156+
<configuration>
157+
<!--为true时执行自动生成-->
158+
<execute>false</execute>
159+
<dbName>knowledge</dbName>
160+
<dbUrl>jdbc:mysql://localhost:3306</dbUrl>
161+
<dbUserName>root</dbUserName>
162+
<dbPassword>123456</dbPassword>
163+
<packageName>org.minbox.framework.knowledge.library.common.entity</packageName>
164+
<tableNamePattern>kl%</tableNamePattern>
165+
</configuration>
166+
</plugin>
167+
</plugins>
168+
</build>
169+
</profile>
170+
</profiles>
132171
<build>
133172
<plugins>
134173
<plugin>
135174
<groupId>org.springframework.boot</groupId>
136175
<artifactId>spring-boot-maven-plugin</artifactId>
137176
<version>${spring-boot.version}</version>
138177
</plugin>
139-
<plugin>
140-
<groupId>org.minbox.framework</groupId>
141-
<artifactId>api-boot-mybatis-enhance-maven-codegen</artifactId>
142-
<version>${api-boot.version}</version>
143-
<dependencies>
144-
<!--数据驱动依赖-->
145-
<dependency>
146-
<groupId>mysql</groupId>
147-
<artifactId>mysql-connector-java</artifactId>
148-
<version>5.1.47</version>
149-
</dependency>
150-
</dependencies>
151-
<executions>
152-
<execution>
153-
<goals>
154-
<goal>generator</goal>
155-
</goals>
156-
</execution>
157-
</executions>
158-
<configuration>
159-
<!--为true时执行自动生成-->
160-
<execute>false</execute>
161-
<dbName>knowledge</dbName>
162-
<dbUrl>jdbc:mysql://localhost:3306</dbUrl>
163-
<dbUserName>root</dbUserName>
164-
<dbPassword>123456</dbPassword>
165-
<packageName>org.minbox.framework.knowledge.library.common.entity</packageName>
166-
<tableNamePattern>kl%</tableNamePattern>
167-
</configuration>
168-
</plugin>
169178
</plugins>
170179
</build>
171180
<dependencyManagement>

api-boot-samples/api-boot-sample-message-pipe-client/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
<artifactId>redisson-spring-boot-starter</artifactId>
2121
<version>3.13.3</version>
2222
</dependency>
23+
<dependency>
24+
<groupId>com.alibaba.nacos</groupId>
25+
<artifactId>nacos-client</artifactId>
26+
<version>1.3.2</version>
27+
</dependency>
2328
<dependency>
2429
<groupId>org.minbox.framework</groupId>
2530
<artifactId>api-boot-starter-message-pipe-client</artifactId>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package org.minbox.framework.api.boot.sample.message.pipe.client;
2+
3+
import com.alibaba.nacos.api.NacosFactory;
4+
import com.alibaba.nacos.api.PropertyKeyConst;
5+
import com.alibaba.nacos.api.exception.NacosException;
6+
import com.alibaba.nacos.api.naming.NamingService;
7+
import org.minbox.framework.message.pipe.spring.annotation.ServerServiceType;
8+
import org.minbox.framework.message.pipe.spring.annotation.client.EnableMessagePipeClient;
9+
import org.springframework.context.annotation.Bean;
10+
import org.springframework.context.annotation.Configuration;
11+
12+
import java.util.Properties;
13+
14+
/**
15+
* 消息管道客户端配置示例
16+
* <p>
17+
* 使用Nacos方式进行注册服务
18+
*
19+
* @author 恒宇少年
20+
*/
21+
@Configuration
22+
@EnableMessagePipeClient(serverType = ServerServiceType.NACOS)
23+
public class MessagePipeClientConfiguration {
24+
/**
25+
* 配置Nacos {@link NamingService}实例
26+
*
27+
* @return
28+
* @throws NacosException
29+
*/
30+
@Bean
31+
public NamingService namingService() throws NacosException {
32+
Properties properties = new Properties();
33+
properties.put(PropertyKeyConst.USERNAME, "nacos");
34+
properties.put(PropertyKeyConst.PASSWORD, "nacos");
35+
properties.put(PropertyKeyConst.SERVER_ADDR, "open.nacos.yuqiyu.com:80");
36+
return NacosFactory.createNamingService(properties);
37+
}
38+
}

api-boot-samples/api-boot-sample-message-pipe-client/src/main/java/org/minbox/framework/api/boot/sample/message/pipe/client/MessagePipeClientSampleApplication.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package org.minbox.framework.api.boot.sample.message.pipe.client;
22

3+
import org.minbox.framework.message.pipe.spring.annotation.ServerServiceType;
4+
import org.minbox.framework.message.pipe.spring.annotation.client.EnableMessagePipeClient;
35
import org.slf4j.Logger;
46
import org.slf4j.LoggerFactory;
57
import org.springframework.boot.SpringApplication;

api-boot-samples/api-boot-sample-message-pipe-client/src/main/java/org/minbox/framework/api/boot/sample/message/pipe/client/processor/TestMessageProcessor.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@
22

33
import lombok.extern.slf4j.Slf4j;
44
import org.minbox.framework.message.pipe.client.process.MessageProcessor;
5+
import org.minbox.framework.message.pipe.core.Message;
6+
import org.minbox.framework.message.pipe.core.untis.JsonUtils;
57
import org.springframework.stereotype.Service;
68

9+
import java.util.Map;
10+
711
/**
812
* 示例 {@link MessageProcessor}
913
*
@@ -20,8 +24,11 @@ public String bindingPipeName() {
2024
}
2125

2226
@Override
23-
public boolean processing(String specificPipeName, String requestId, byte[] messageBody) {
24-
log.info("具体管道:{},消费消息:{},内容:{}", specificPipeName, requestId, new String(messageBody));
27+
public boolean processing(String specificPipeName, String requestId, Message message) {
28+
Map<String, Object> metadata = message.getMetadata();
29+
byte[] messageBody = message.getBody();
30+
log.info("具体管道:{},消费消息:{},内容:{},元数据:{}",
31+
specificPipeName, requestId, new String(messageBody), JsonUtils.objectToJson(metadata));
2532
return true;
2633
}
2734
}

api-boot-samples/api-boot-sample-message-pipe-server/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
<artifactId>redisson-spring-boot-starter</artifactId>
2121
<version>3.13.3</version>
2222
</dependency>
23+
<dependency>
24+
<groupId>com.alibaba.nacos</groupId>
25+
<artifactId>nacos-client</artifactId>
26+
<version>1.3.2</version>
27+
</dependency>
2328
<dependency>
2429
<groupId>org.minbox.framework</groupId>
2530
<artifactId>api-boot-starter-message-pipe-server</artifactId>

api-boot-samples/api-boot-sample-message-pipe-server/src/main/java/org/minbox/framework/api/boot/sample/message/pipe/server/MessagePipeServerConfiguration.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
package org.minbox.framework.api.boot.sample.message.pipe.server;
22

3+
import com.alibaba.nacos.api.NacosFactory;
4+
import com.alibaba.nacos.api.PropertyKeyConst;
5+
import com.alibaba.nacos.api.exception.NacosException;
6+
import com.alibaba.nacos.api.naming.NamingService;
37
import org.minbox.framework.message.pipe.server.processing.push.PushMessageEvent;
48
import org.minbox.framework.message.pipe.spring.annotation.ServerServiceType;
59
import org.minbox.framework.message.pipe.spring.annotation.server.EnableMessagePipeServer;
@@ -8,13 +12,15 @@
812
import org.springframework.data.redis.connection.RedisConnectionFactory;
913
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
1014

15+
import java.util.Properties;
16+
1117
/**
1218
* 消息管道Server相关配置
1319
*
1420
* @author 恒宇少年
1521
*/
1622
@Configuration
17-
@EnableMessagePipeServer(serverType = ServerServiceType.GRPC)
23+
@EnableMessagePipeServer(serverType = ServerServiceType.NACOS)
1824
public class MessagePipeServerConfiguration {
1925
/**
2026
* 配置Redis监听容器
@@ -32,4 +38,18 @@ public RedisMessageListenerContainer redisMessageListenerContainer(RedisConnecti
3238
return container;
3339
}
3440

41+
/**
42+
* 配置Nacos {@link NamingService}实例
43+
*
44+
* @return
45+
* @throws NacosException
46+
*/
47+
@Bean
48+
public NamingService namingService() throws NacosException {
49+
Properties properties = new Properties();
50+
properties.put(PropertyKeyConst.USERNAME, "nacos");
51+
properties.put(PropertyKeyConst.PASSWORD, "nacos");
52+
properties.put(PropertyKeyConst.SERVER_ADDR, "open.nacos.yuqiyu.com:80");
53+
return NacosFactory.createNamingService(properties);
54+
}
3555
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package org.minbox.framework.api.boot.sample.message.pipe.server;
2+
3+
import org.minbox.framework.message.pipe.core.Message;
4+
import org.minbox.framework.message.pipe.server.MessagePipe;
5+
import org.minbox.framework.message.pipe.server.manager.MessagePipeManager;
6+
import org.springframework.beans.factory.InitializingBean;
7+
import org.springframework.beans.factory.annotation.Autowired;
8+
import org.springframework.context.annotation.Configuration;
9+
10+
import java.util.UUID;
11+
import java.util.concurrent.Executors;
12+
import java.util.concurrent.ScheduledExecutorService;
13+
import java.util.concurrent.TimeUnit;
14+
15+
/**
16+
* 将消息{@link Message}定时写入消息管道{@link MessagePipe}测试类
17+
*
18+
* @author 恒宇少年
19+
*/
20+
@Configuration
21+
public class PutMessage implements InitializingBean {
22+
@Autowired
23+
private MessagePipeManager messagePipeManager;
24+
private ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(1);
25+
26+
@Override
27+
public void afterPropertiesSet() throws Exception {
28+
scheduledExecutorService.scheduleWithFixedDelay(() -> {
29+
MessagePipe messagePipe = messagePipeManager.getMessagePipe("test");
30+
// 随机uuid作为内容
31+
String content = UUID.randomUUID().toString();
32+
Message message = new Message(content.getBytes());
33+
// 设置元数据
34+
message.getMetadata().put("traceId", System.currentTimeMillis());
35+
messagePipe.putLast(message);
36+
}, 1000, 1000, TimeUnit.MILLISECONDS);
37+
}
38+
}

api-boot-samples/api-boot-sample-mybatis-enhance-codegen/pom.xml

Lines changed: 38 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -60,42 +60,51 @@
6060
</dependency>
6161
</dependencies>
6262
</dependencyManagement>
63+
<profiles>
64+
<profile>
65+
<id>codegen</id>
66+
<build>
67+
<plugins>
68+
<plugin>
69+
<groupId>org.minbox.framework</groupId>
70+
<artifactId>api-boot-mybatis-enhance-maven-codegen</artifactId>
71+
<version>${api-boot.version}</version>
72+
<dependencies>
73+
<!--数据驱动依赖-->
74+
<dependency>
75+
<groupId>mysql</groupId>
76+
<artifactId>mysql-connector-java</artifactId>
77+
<version>5.1.47</version>
78+
</dependency>
79+
</dependencies>
80+
<executions>
81+
<execution>
82+
<goals>
83+
<goal>generator</goal>
84+
</goals>
85+
</execution>
86+
</executions>
87+
<configuration>
88+
<execute>false</execute>
89+
<dbName>knowledge</dbName>
90+
<dbUrl>jdbc:mysql://localhost:3306</dbUrl>
91+
<dbUserName>root</dbUserName>
92+
<dbPassword>123456</dbPassword>
93+
<packageName>org.minbox.framework.api.boot.sample</packageName>
94+
<tableNamePattern>kl%</tableNamePattern>
95+
</configuration>
96+
</plugin>
97+
</plugins>
98+
</build>
99+
</profile>
100+
</profiles>
63101
<build>
64102
<plugins>
65103
<plugin>
66104
<groupId>org.springframework.boot</groupId>
67105
<artifactId>spring-boot-maven-plugin</artifactId>
68106
<version>${spring-boot.version}</version>
69107
</plugin>
70-
<plugin>
71-
<groupId>org.minbox.framework</groupId>
72-
<artifactId>api-boot-mybatis-enhance-maven-codegen</artifactId>
73-
<version>2.3.1.RELEASE</version>
74-
<dependencies>
75-
<!--数据驱动依赖-->
76-
<dependency>
77-
<groupId>mysql</groupId>
78-
<artifactId>mysql-connector-java</artifactId>
79-
<version>5.1.47</version>
80-
</dependency>
81-
</dependencies>
82-
<executions>
83-
<execution>
84-
<goals>
85-
<goal>generator</goal>
86-
</goals>
87-
</execution>
88-
</executions>
89-
<configuration>
90-
<execute>false</execute>
91-
<dbName>knowledge</dbName>
92-
<dbUrl>jdbc:mysql://localhost:3306</dbUrl>
93-
<dbUserName>root</dbUserName>
94-
<dbPassword>123456</dbPassword>
95-
<packageName>org.minbox.framework.api.boot.sample</packageName>
96-
<tableNamePattern>kl%</tableNamePattern>
97-
</configuration>
98-
</plugin>
99108
</plugins>
100109
</build>
101110
</project>

0 commit comments

Comments
 (0)