From 6acb1c968a35ffac1d4c55664e4eed919d0fe3b2 Mon Sep 17 00:00:00 2001 From: heavyrian2012 Date: Sun, 23 Oct 2022 09:48:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0h2db=E8=B7=AF=E5=BE=84?= =?UTF-8?q?=E7=9A=84=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- broker/config/wildfirechat.conf | 3 +++ broker/src/main/java/io/moquette/BrokerConstants.java | 2 ++ broker/src/main/java/win/liyufan/im/DBUtil.java | 3 ++- distribution/src/main/resources/wildfirechat.conf | 3 +++ 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/broker/config/wildfirechat.conf b/broker/config/wildfirechat.conf index 913ec7f6..16d93c0a 100755 --- a/broker/config/wildfirechat.conf +++ b/broker/config/wildfirechat.conf @@ -42,6 +42,9 @@ embed.db 1 ## 使用mongodb时次开关无效(因为mongodb设置了消息过期时间,会自动清理,仅专业版支持mongodb)。 db.auto_clean_history_messages true +## h2db数据库的路径,默认为程序目录下的,可以指定其他目录。如果使用MySQL,可以忽略此配置 +h2db.path ./h2db/wfchat + ##服务器管理接口密钥。如果修改此端口需要同步修改使用管理API的地方,比如应用服务。 http.admin.secret_key 123456 diff --git a/broker/src/main/java/io/moquette/BrokerConstants.java b/broker/src/main/java/io/moquette/BrokerConstants.java index eed919cb..e25ee747 100755 --- a/broker/src/main/java/io/moquette/BrokerConstants.java +++ b/broker/src/main/java/io/moquette/BrokerConstants.java @@ -112,6 +112,8 @@ public final class BrokerConstants { public static final String EMBED_DB_PROPERTY_NAME = "embed.db"; public static final String DB_AUTO_CLEAN_HISTORY_MESSAGES = "db.auto_clean_history_messages"; + public static final String H2DB_PATH = "h2db.path"; + public static final String SENSITIVE_Filter_Type = "sensitive.filter.type"; diff --git a/broker/src/main/java/win/liyufan/im/DBUtil.java b/broker/src/main/java/win/liyufan/im/DBUtil.java index 4d448bed..3cbaf8dd 100755 --- a/broker/src/main/java/win/liyufan/im/DBUtil.java +++ b/broker/src/main/java/win/liyufan/im/DBUtil.java @@ -49,6 +49,7 @@ public class DBUtil { public static void init(IConfig config) { String embedDB = config.getProperty(BrokerConstants.EMBED_DB_PROPERTY_NAME); + String h2dbPath = config.getProperty(BrokerConstants.H2DB_PATH, "./h2db/wfchat"); boolean autoCleanMsgs = "true".equals(config.getProperty(BrokerConstants.DB_AUTO_CLEAN_HISTORY_MESSAGES)); if (embedDB != null && embedDB.equals("1")) { IsEmbedDB = true; @@ -67,7 +68,7 @@ public class DBUtil { migrateLocation = "filesystem:./migrate/h2"; comboPooledDataSource = new ComboPooledDataSource(); - comboPooledDataSource.setJdbcUrl( "jdbc:h2:./h2db/wfchat;AUTO_SERVER=TRUE;MODE=MySQL" ); + comboPooledDataSource.setJdbcUrl( "jdbc:h2:" + h2dbPath + ";AUTO_SERVER=TRUE;MODE=MySQL" ); comboPooledDataSource.setUser("SA"); comboPooledDataSource.setPassword("SA"); comboPooledDataSource.setMinPoolSize(5); diff --git a/distribution/src/main/resources/wildfirechat.conf b/distribution/src/main/resources/wildfirechat.conf index 4c3dc346..565ec57d 100755 --- a/distribution/src/main/resources/wildfirechat.conf +++ b/distribution/src/main/resources/wildfirechat.conf @@ -40,6 +40,9 @@ embed.db 1 ## 使用mongodb时次开关无效(因为mongodb设置了消息过期时间,会自动清理,仅专业版支持mongodb)。 db.auto_clean_history_messages true +## h2db数据库的路径,默认为程序目录下的,可以指定其他目录。如果使用MySQL,可以忽略此配置 +h2db.path ./h2db/wfchat + ##服务器管理接口密钥。如果修改此端口需要同步修改使用管理API的地方,比如应用服务。 http.admin.secret_key 123456