try {
// Send a small, simple identify command to the server and if it succeeds, tell the client
// sender that it is OK to start sending messages, if it is not already sending
IdentifyCommand id_cmd = new IdentifyCommand();
m_clientSender.preprocessCommand(id_cmd);
CommandResponse response = m_clientSender.send(id_cmd);
// let all our listeners know what the results of the poll was
for (PollingListener listener : m_pollingListeners) {
try {
listener.pollResponse(response);
} catch (Throwable t) {
// should never happen, but I'm paranoid
}
}
// there are special cases when we might get a response back but it should be considered "server down".
// 1) when the server replies with a NotProcessedException response
// 2) when our failover mechanism runs out of retries and it can't find a server to process our request,
// the comm layer will reply with a failoverable exception.
// In both cases, our CommUtils will detect this.
if (CommUtils.isExceptionFailoverable(response.getException())) {
throw response.getException();
}
if (m_clientSender.startSending()) {
LOG.info(CommI18NResourceKeys.SERVER_POLLING_THREAD_SERVER_ONLINE);
m_warnedAboutConnectionFailure = false; // if we detect the server is down again, lets log the exception again