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 #*********************************************************************