clebertsuconic commented on a change in pull request #3714:
URL: https://github.com/apache/activemq-artemis/pull/3714#discussion_r701415249



##########
File path: 
artemis-protocols/artemis-mqtt-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/mqtt/MQTTProtocolManagerFactory.java
##########
@@ -64,4 +74,46 @@ public ProtocolManager createProtocolManager(ActiveMQServer 
server,
    public String getModuleName() {
       return MODULE_NAME;
    }
+
+
+   @Override
+   public void loadProtocolServices(ActiveMQServer server, 
List<ActiveMQComponent> services) {
+      services.add(new MQTTPeriodicTasks(server.getScheduledPool()));
+   }
+
+   public class MQTTPeriodicTasks implements ActiveMQComponent {
+      ScheduledExecutorService pool;
+      Runnable runnable;
+
+      public MQTTPeriodicTasks(ScheduledExecutorService pool) {

Review comment:
       ```suggestion
      public class MQTTPeriodicTasks extends ActiveMQScheduledComponent {
         public MQTTPeriodicTasks(ScheduledExecutorService 
scheduledExecutorService) {
            super(scheduledExecutorService, null, 5, TimeUnit.SECONDS, false);
         }
   
         @Override
         public void run() {
            for (Map.Entry<String, MQTTSessionState> entry : 
sessionStates.entrySet()) {
               MQTTSessionState state = entry.getValue();
               if (logger.isDebugEnabled()) {
                  logger.debug("Inspecting session state: " + state);
               }
               if (!state.getAttached() && defaultMqttSessionExiryInterval != 
-1 && state.getDisconnectedTime() + (defaultMqttSessionExiryInterval * 1000) < 
System.currentTimeMillis()) {
                  if (logger.isDebugEnabled()) {
                     logger.debug("Removing expired session state: " + state);
                  }
                  sessionStates.remove(entry.getKey());
               }
            }
         }
      }
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to