@Override
    public void run() {
      while (!closed) {
        try {
          long now = System.currentTimeMillis();

          Set<Object> idsToRemove = new HashSet<Object>();

          for (ConnectionEntry entry : connections.values()) {
            RemotingConnection conn = entry.connection;

            boolean flush = true;

            if (entry.ttl != -1) {
              if (!conn.checkDataReceived()) {
                if (now >= entry.lastCheck + entry.ttl) {
                  idsToRemove.add(conn.getID());

                  flush = false;
                }
              } else {
                entry.lastCheck = now;
              }
            }

            if (flush) {
              conn.flush();
            }
          }

          for (Object id : idsToRemove) {
            RemotingConnection conn = removeConnection(id);
            if (conn != null) {
              conn.fail(HornetQMessageBundle.BUNDLE.clientExited(conn.getRemoteAddress()));
            }
          }

          if (latch.await(pauseInterval, TimeUnit.MILLISECONDS)) return;
        } catch (Throwable e) {
          HornetQServerLogger.LOGGER.errorOnFailureCheck(e);
        }
      }
    }
Example #2
0
 public Object getConnectionID() {
   return remotingConnection.getID();
 }