mirror of
https://gitee.com/beecue/fastbee.git
synced 2025-12-17 16:36:03 +08:00
更新
This commit is contained in:
35
springboot/fastbee-server/boot-strap/pom.xml
Normal file
35
springboot/fastbee-server/boot-strap/pom.xml
Normal file
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<artifactId>fastbee-server</artifactId>
|
||||
<groupId>com.fastbee</groupId>
|
||||
<version>3.8.5</version>
|
||||
</parent>
|
||||
<artifactId>boot-strap</artifactId>
|
||||
<description>网关服务启动模块</description>
|
||||
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.fastbee</groupId>
|
||||
<artifactId>mqtt-broker</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fastbee</groupId>
|
||||
<artifactId>fastbee-protocol-collect</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fastbee</groupId>
|
||||
<artifactId>base-server</artifactId>
|
||||
<version>3.8.5</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.fastbee.bootstrap.mqtt;
|
||||
|
||||
import com.fastbee.mqtt.server.MqttServer;
|
||||
import com.fastbee.mqtt.server.WebSocketServer;
|
||||
import com.fastbee.server.Server;
|
||||
import com.fastbee.server.config.NettyConfig;
|
||||
import com.fastbee.common.enums.ServerType;
|
||||
import lombok.Data;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.annotation.Order;
|
||||
|
||||
/**
|
||||
* MQTT-BROKER启动
|
||||
* @author gsb
|
||||
* @date 2022/9/17 17:25
|
||||
*/
|
||||
@Order(10)
|
||||
@Configuration
|
||||
@ConfigurationProperties(value = "server.broker")
|
||||
@Data
|
||||
public class MQTTBootStrap {
|
||||
|
||||
@Autowired
|
||||
private MqttServer mqttServer;
|
||||
@Autowired
|
||||
private WebSocketServer webSocketServer;
|
||||
/*服务器集群节点*/
|
||||
private String brokerNode;
|
||||
/*端口*/
|
||||
private int port;
|
||||
/*心跳时间*/
|
||||
private int keepAlive;
|
||||
/*webSocket端口*/
|
||||
private int websocketPort;
|
||||
/*webSocket路由*/
|
||||
private String websocketPath;
|
||||
|
||||
|
||||
/**
|
||||
* 启动mqttBroker
|
||||
* @return server
|
||||
*/
|
||||
@ConditionalOnProperty(value = "server.broker.enabled", havingValue = "true")
|
||||
@Bean(initMethod = "start", destroyMethod = "stop")
|
||||
public Server mqttBroker() {
|
||||
return NettyConfig.custom()
|
||||
.setIdleStateTime(0,0,keepAlive)
|
||||
.setName(ServerType.MQTT.getDes())
|
||||
.setType(ServerType.MQTT)
|
||||
.setPort(port)
|
||||
.setServer(mqttServer)
|
||||
.build();
|
||||
}
|
||||
|
||||
@ConditionalOnProperty(value = "server.broker.enabled", havingValue = "true")
|
||||
@Bean(initMethod = "start",destroyMethod = "stop")
|
||||
public Server webSocket(){
|
||||
return NettyConfig.custom()
|
||||
.setIdleStateTime(0,0,keepAlive)
|
||||
.setName(ServerType.WEBSOCKET.getDes())
|
||||
.setType(ServerType.WEBSOCKET)
|
||||
.setPort(websocketPort)
|
||||
.setServer(webSocketServer)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user