From 994a8b5c4a8ba8ef50ccf2dafbe0a6c3b1555931 Mon Sep 17 00:00:00 2001 From: imhao183 Date: Tue, 3 Dec 2019 08:10:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=9C=8D=E5=8A=A1=E5=99=A8?= =?UTF-8?q?=E4=B8=BA=E5=AE=A2=E6=88=B7=E7=BC=93=E5=AD=98=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E6=95=B0=E9=87=8F=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 | 3 +++ .../java/io/moquette/persistence/MemoryMessagesStore.java | 2 ++ broker/src/main/java/io/moquette/server/Constants.java | 6 ++++-- distribution/src/main/resources/wildfirechat.conf | 3 +++ 5 files changed, 15 insertions(+), 2 deletions(-) diff --git a/broker/config/wildfirechat.conf b/broker/config/wildfirechat.conf index 25fe71681..899e7a7e4 100755 --- a/broker/config/wildfirechat.conf +++ b/broker/config/wildfirechat.conf @@ -58,6 +58,9 @@ message.roaming 0 ##是否开启拉取远程历史消息 message.remote_history_message 0 +##服务器为每个用户缓存的消息数量 +message.max_queue 1024 + #********************************************************************* # hazelcase configuration #********************************************************************* diff --git a/broker/src/main/java/io/moquette/BrokerConstants.java b/broker/src/main/java/io/moquette/BrokerConstants.java index ac93823bc..b7c117541 100755 --- a/broker/src/main/java/io/moquette/BrokerConstants.java +++ b/broker/src/main/java/io/moquette/BrokerConstants.java @@ -115,6 +115,9 @@ public final class BrokerConstants { public static final String MESSAGE_ROAMING = "message.roaming"; public static final String MESSAGE_Remote_History_Message = "message.remote_history_message"; + public static final String MESSAGE_Max_Queue = "message.max_queue"; + + private BrokerConstants() { } diff --git a/broker/src/main/java/io/moquette/persistence/MemoryMessagesStore.java b/broker/src/main/java/io/moquette/persistence/MemoryMessagesStore.java index f6d30e641..66c0c0215 100755 --- a/broker/src/main/java/io/moquette/persistence/MemoryMessagesStore.java +++ b/broker/src/main/java/io/moquette/persistence/MemoryMessagesStore.java @@ -25,6 +25,7 @@ import com.xiaoleilu.loServer.model.FriendData; import cn.wildfirechat.pojos.InputOutputUserBlockStatus; import cn.wildfirechat.common.ErrorCode; +import io.moquette.server.Constants; import io.moquette.server.Server; import io.moquette.spi.IMatchingCondition; import io.moquette.spi.IMessagesStore; @@ -123,6 +124,7 @@ public class MemoryMessagesStore implements IMessagesStore { this.databaseStore = databaseStore; IS_MESSAGE_ROAMING = "1".equals(m_Server.getConfig().getProperty(MESSAGE_ROAMING)); IS_MESSAGE_REMOTE_HISTORY_MESSAGE = "1".equals(m_Server.getConfig().getProperty(MESSAGE_Remote_History_Message)); + Constants.MAX_MESSAGE_QUEUE = Integer.parseInt(m_Server.getConfig().getProperty(MESSAGE_Max_Queue)); } @Override diff --git a/broker/src/main/java/io/moquette/server/Constants.java b/broker/src/main/java/io/moquette/server/Constants.java index d2fccd16d..2b8bcfc00 100644 --- a/broker/src/main/java/io/moquette/server/Constants.java +++ b/broker/src/main/java/io/moquette/server/Constants.java @@ -24,8 +24,10 @@ public final class Constants { public static final String ATTR_CLIENTID = "ClientID"; public static final String CLEAN_SESSION = "cleanSession"; public static final String KEEP_ALIVE = "keepAlive"; - public static final int MAX_MESSAGE_QUEUE = 1024; // number of messages - public static final int MAX_CHATROOM_MESSAGE_QUEUE = 256; // number of chatroom messages + + + public static int MAX_MESSAGE_QUEUE = 1024; // number of messages + public static int MAX_CHATROOM_MESSAGE_QUEUE = 256; // number of chatroom messages private Constants() { } diff --git a/distribution/src/main/resources/wildfirechat.conf b/distribution/src/main/resources/wildfirechat.conf index 8a75bfd7a..872854af4 100755 --- a/distribution/src/main/resources/wildfirechat.conf +++ b/distribution/src/main/resources/wildfirechat.conf @@ -49,6 +49,9 @@ message.roaming 0 ##是否开启拉取远程历史消息 message.remote_history_message 0 +##服务器为每个用户缓存的消息数量 +message.max_queue 1024 + #********************************************************************* # hazelcase configuration #*********************************************************************