diff --git a/broker/config/wildfirechat.conf b/broker/config/wildfirechat.conf index 8665ea5d..2309974d 100755 --- a/broker/config/wildfirechat.conf +++ b/broker/config/wildfirechat.conf @@ -57,10 +57,13 @@ token.key testim ##token.expire_time 2592000000 ##首次登录,是否接收之前的历史消息。 -##0 不接收历史消息,只接收5分钟以内的消息,由于服务器没有保存已经收取记录,所以如果有超过5分钟之前未收取的消息也不会收取下拉; +##0 不接收历史消息,只接收${message.compensate_time_limit}毫秒以内的消息,由于服务器没有保存已经收取记录,所以如果有超过${message.compensate_time_limit}毫秒之前未收取的消息也不会收取下拉; ##1接收,会接收 message.max_queue 配置的条数的历史消息 message.roaming 0 +## 消息补偿时限,当${message.roaming}为0时,会同步时限以内且小于${message.max_queue}的消息,默认时限为5分钟。当${message.roaming}为1时,会接收 message.max_queue 配置的条数的历史消息。 +message.compensate_time_limit 300000 + ##是否开启拉取远程历史消息。如果为1,客户端在会话内如果本地消息读取完了,可以下拉继续加载在服务器上的该会话的消息;如果为0则不能。 message.remote_history_message 0 diff --git a/broker/src/main/java/io/moquette/BrokerConstants.java b/broker/src/main/java/io/moquette/BrokerConstants.java index ca0ba4fc..845d18bd 100755 --- a/broker/src/main/java/io/moquette/BrokerConstants.java +++ b/broker/src/main/java/io/moquette/BrokerConstants.java @@ -131,6 +131,7 @@ public final class BrokerConstants { public static final String SERVER_CLIENT_SUPPORT_KICKOFF_EVENT = "server.client_support_kickoff_event"; public static final String MESSAGE_ROAMING = "message.roaming"; + public static final String MESSAGE_Compensate_Time_Limit = "message.compensate_time_limit"; public static final String MESSAGE_Remote_History_Message = "message.remote_history_message"; public static final String MESSAGE_Remote_Chatroom_History_Message = "message.chatroom_remote_history_message"; diff --git a/broker/src/main/java/io/moquette/persistence/MemoryMessagesStore.java b/broker/src/main/java/io/moquette/persistence/MemoryMessagesStore.java index 88461975..bbe2ce3e 100755 --- a/broker/src/main/java/io/moquette/persistence/MemoryMessagesStore.java +++ b/broker/src/main/java/io/moquette/persistence/MemoryMessagesStore.java @@ -96,6 +96,7 @@ public class MemoryMessagesStore implements IMessagesStore { private static final String CHANNEL_LISTENERS = "channel_listeners"; private static boolean IS_MESSAGE_ROAMING = true; + private static long msgCompensateTimeLimit = 300000; private static boolean IS_MESSAGE_REMOTE_HISTORY_MESSAGE = true; private static boolean IS_CHATROOM_MESSAGE_REMOTE_HISTORY_MESSAGE = true; @@ -178,6 +179,11 @@ public class MemoryMessagesStore implements IMessagesStore { this.databaseStore = databaseStore; IS_MESSAGE_ROAMING = "1".equals(m_Server.getConfig().getProperty(MESSAGE_ROAMING)); + try { + msgCompensateTimeLimit = Long.parseLong(m_Server.getConfig().getProperty(MESSAGE_Compensate_Time_Limit, "300000")); + } catch (NumberFormatException e) { + + } IS_MESSAGE_REMOTE_HISTORY_MESSAGE = "1".equals(m_Server.getConfig().getProperty(MESSAGE_Remote_History_Message)); IS_CHATROOM_MESSAGE_REMOTE_HISTORY_MESSAGE = "1".equals(m_Server.getConfig().getProperty(MESSAGE_Remote_Chatroom_History_Message, "1")); Constants.MAX_MESSAGE_QUEUE = Integer.parseInt(m_Server.getConfig().getProperty(MESSAGE_Max_Queue)); @@ -739,7 +745,7 @@ public class MemoryMessagesStore implements IMessagesStore { } } - if (noRoaming && (System.currentTimeMillis() - bundle.getMessage().getServerTimestamp() > 5 * 60 * 1000)) { + if (noRoaming && (System.currentTimeMillis() - bundle.getMessage().getServerTimestamp() > msgCompensateTimeLimit)) { continue; } diff --git a/distribution/src/main/resources/wildfirechat.conf b/distribution/src/main/resources/wildfirechat.conf index 4fe0cedb..9343fee6 100755 --- a/distribution/src/main/resources/wildfirechat.conf +++ b/distribution/src/main/resources/wildfirechat.conf @@ -53,10 +53,13 @@ token.key testim ##token.expire_time 2592000000 ##首次登录,是否接收之前的历史消息。 -##0 不接收历史消息,只接收5分钟以内的消息,由于服务器没有保存已经收取记录,所以如果有超过5分钟之前未收取的消息也不会收取下拉; +##0 不接收历史消息,只接收${message.compensate_time_limit}毫秒以内的消息,由于服务器没有保存已经收取记录,所以如果有超过${message.compensate_time_limit}毫秒之前未收取的消息也不会收取下拉; ##1接收,会接收 message.max_queue 配置的条数的历史消息 message.roaming 0 +## 消息补偿时限,当${message.roaming}为0时,会同步时限以内且小于${message.max_queue}的消息,默认时限为5分钟。当${message.roaming}为1时,会接收 message.max_queue 配置的条数的历史消息。 +message.compensate_time_limit 300000 + ##是否开启拉取远程历史消息。如果为1,客户端在会话内如果本地消息读取完了,可以下拉继续加载在服务器上的该会话的消息;如果为0则不能。 message.remote_history_message 0