1. 统一包名修改

This commit is contained in:
chenbowen
2025-09-22 14:53:45 +08:00
parent 0d46897482
commit 386d47fde1
692 changed files with 2132 additions and 2132 deletions

View File

@@ -12,7 +12,7 @@ import jakarta.validation.constraints.NotNull;
*
* @author xingyu4j
*/
@ConfigurationProperties("cloud.websocket")
@ConfigurationProperties("zt.websocket")
@Data
@Validated
public class WebSocketProperties {

View File

@@ -1,6 +1,6 @@
package com.zt.plat.framework.websocket.config;
import com.zt.plat.framework.mq.redis.config.CloudRedisMQConsumerAutoConfiguration;
import com.zt.plat.framework.mq.redis.config.ZtRedisMQConsumerAutoConfiguration;
import com.zt.plat.framework.mq.redis.core.RedisMQTemplate;
import com.zt.plat.framework.websocket.core.handler.JsonWebSocketMessageHandler;
import com.zt.plat.framework.websocket.core.listener.WebSocketMessageListener;
@@ -40,11 +40,11 @@ import java.util.List;
*
* @author xingyu4j
*/
@AutoConfiguration(before = CloudRedisMQConsumerAutoConfiguration.class) // before CloudRedisMQConsumerAutoConfiguration 的原因是需要保证 RedisWebSocketMessageConsumer 先创建才能创建 RedisMessageListenerContainer
@AutoConfiguration(before = ZtRedisMQConsumerAutoConfiguration.class) // before ZtRedisMQConsumerAutoConfiguration 的原因是需要保证 RedisWebSocketMessageConsumer 先创建才能创建 RedisMessageListenerContainer
@EnableWebSocket // 开启 websocket
@ConditionalOnProperty(prefix = "cloud.websocket", value = "enable", matchIfMissing = true) // 允许使用 cloud.websocket.enable=false 禁用 websocket
@ConditionalOnProperty(prefix = "zt.websocket", value = "enable", matchIfMissing = true) // 允许使用 zt.websocket.enable=false 禁用 websocket
@EnableConfigurationProperties(WebSocketProperties.class)
public class CloudWebSocketAutoConfiguration {
public class ZtWebSocketAutoConfiguration {
@Bean
public WebSocketConfigurer webSocketConfigurer(HandshakeInterceptor[] handshakeInterceptors,
@@ -85,7 +85,7 @@ public class CloudWebSocketAutoConfiguration {
// ==================== Sender 相关 ====================
@Configuration
@ConditionalOnProperty(prefix = "cloud.websocket", name = "sender-type", havingValue = "local")
@ConditionalOnProperty(prefix = "zt.websocket", name = "sender-type", havingValue = "local")
public class LocalWebSocketMessageSenderConfiguration {
@Bean
@@ -96,7 +96,7 @@ public class CloudWebSocketAutoConfiguration {
}
@Configuration
@ConditionalOnProperty(prefix = "cloud.websocket", name = "sender-type", havingValue = "redis")
@ConditionalOnProperty(prefix = "zt.websocket", name = "sender-type", havingValue = "redis")
public class RedisWebSocketMessageSenderConfiguration {
@Bean
@@ -114,13 +114,13 @@ public class CloudWebSocketAutoConfiguration {
}
@Configuration
@ConditionalOnProperty(prefix = "cloud.websocket", name = "sender-type", havingValue = "rocketmq")
@ConditionalOnProperty(prefix = "zt.websocket", name = "sender-type", havingValue = "rocketmq")
public class RocketMQWebSocketMessageSenderConfiguration {
@Bean
public RocketMQWebSocketMessageSender rocketMQWebSocketMessageSender(
WebSocketSessionManager sessionManager, RocketMQTemplate rocketMQTemplate,
@Value("${cloud.websocket.sender-rocketmq.topic}") String topic) {
@Value("${zt.websocket.sender-rocketmq.topic}") String topic) {
return new RocketMQWebSocketMessageSender(sessionManager, rocketMQTemplate, topic);
}
@@ -133,7 +133,7 @@ public class CloudWebSocketAutoConfiguration {
}
@Configuration
@ConditionalOnProperty(prefix = "cloud.websocket", name = "sender-type", havingValue = "rabbitmq")
@ConditionalOnProperty(prefix = "zt.websocket", name = "sender-type", havingValue = "rabbitmq")
public class RabbitMQWebSocketMessageSenderConfiguration {
@Bean
@@ -153,7 +153,7 @@ public class CloudWebSocketAutoConfiguration {
* 创建 Topic Exchange
*/
@Bean
public TopicExchange websocketTopicExchange(@Value("${cloud.websocket.sender-rabbitmq.exchange}") String exchange) {
public TopicExchange websocketTopicExchange(@Value("${zt.websocket.sender-rabbitmq.exchange}") String exchange) {
return new TopicExchange(exchange,
true, // durable: 是否持久化
false); // exclusive: 是否排它
@@ -162,13 +162,13 @@ public class CloudWebSocketAutoConfiguration {
}
@Configuration
@ConditionalOnProperty(prefix = "cloud.websocket", name = "sender-type", havingValue = "kafka")
@ConditionalOnProperty(prefix = "zt.websocket", name = "sender-type", havingValue = "kafka")
public class KafkaWebSocketMessageSenderConfiguration {
@Bean
public KafkaWebSocketMessageSender kafkaWebSocketMessageSender(
WebSocketSessionManager sessionManager, KafkaTemplate<Object, Object> kafkaTemplate,
@Value("${cloud.websocket.sender-kafka.topic}") String topic) {
@Value("${zt.websocket.sender-kafka.topic}") String topic) {
return new KafkaWebSocketMessageSender(sessionManager, kafkaTemplate, topic);
}

View File

@@ -16,9 +16,9 @@ public class KafkaWebSocketMessageConsumer {
@RabbitHandler
@KafkaListener(
topics = "${cloud.websocket.sender-kafka.topic}",
topics = "${zt.websocket.sender-kafka.topic}",
// 在 Group 上,使用 UUID 生成其后缀。这样,启动的 Consumer 的 Group 不同,以达到广播消费的目的
groupId = "${cloud.websocket.sender-kafka.consumer-group}" + "-" + "#{T(java.util.UUID).randomUUID()}")
groupId = "${zt.websocket.sender-kafka.consumer-group}" + "-" + "#{T(java.util.UUID).randomUUID()}")
public void onMessage(KafkaWebSocketMessage message) {
kafkaWebSocketMessageSender.send(message.getSessionId(),
message.getUserType(), message.getUserId(),

View File

@@ -13,12 +13,12 @@ import org.springframework.amqp.rabbit.annotation.*;
bindings = @QueueBinding(
value = @Queue(
// 在 Queue 的名字上,使用 UUID 生成其后缀。这样,启动的 Consumer 的 Queue 不同,以达到广播消费的目的
name = "${cloud.websocket.sender-rabbitmq.queue}" + "-" + "#{T(java.util.UUID).randomUUID()}",
name = "${zt.websocket.sender-rabbitmq.queue}" + "-" + "#{T(java.util.UUID).randomUUID()}",
// Consumer 关闭时,该队列就可以被自动删除了
autoDelete = "true"
),
exchange = @Exchange(
name = "${cloud.websocket.sender-rabbitmq.exchange}",
name = "${zt.websocket.sender-rabbitmq.exchange}",
type = ExchangeTypes.TOPIC,
declare = "false"
)

View File

@@ -11,8 +11,8 @@ import org.apache.rocketmq.spring.core.RocketMQListener;
* @author ZT
*/
@RocketMQMessageListener( // 重点:添加 @RocketMQMessageListener 注解,声明消费的 topic
topic = "${cloud.websocket.sender-rocketmq.topic}",
consumerGroup = "${cloud.websocket.sender-rocketmq.consumer-group}",
topic = "${zt.websocket.sender-rocketmq.topic}",
consumerGroup = "${zt.websocket.sender-rocketmq.consumer-group}",
messageModel = MessageModel.BROADCASTING // 设置为广播模式,保证每个实例都能收到消息
)
@RequiredArgsConstructor

View File

@@ -1 +1 @@
com.zt.plat.framework.websocket.config.CloudWebSocketAutoConfiguration
com.zt.plat.framework.websocket.config.ZtWebSocketAutoConfiguration

View File

@@ -1 +1 @@
<http://www.iocoder.cn/Spring-Boot/WebSocket/?cloud>
<http://www.iocoder.cn/Spring-Boot/WebSocket/?zt>