Set<Object> idsToRemove = new HashSet<Object>();
for (ConnectionEntry entry : connections.values())
{
RemotingConnection conn = entry.connection;
boolean flush = true;
if (entry.ttl != -1)
{
if (now >= entry.lastCheck + entry.ttl)
{
if (!conn.checkDataReceived())
{
idsToRemove.add(conn.getID());
flush = false;
}
else
{
entry.lastCheck = now;
}
}
}
if (flush)
{
conn.flush();
}
}
for (Object id : idsToRemove)
{
RemotingConnection conn = removeConnection(id);
HornetQException me = new HornetQException(HornetQException.CONNECTION_TIMEDOUT,
"Did not receive ping from " + conn.getRemoteAddress() +
". It is likely the client has exited or crashed without " +
"closing its connection, or the network between the server and client has failed. The connection will now be closed.");
conn.fail(me);
}
synchronized (this)
{
long toWait = pauseInterval;