mirror of
https://github.com/correl/mage.git
synced 2024-12-25 11:11:16 +00:00
streamlined Callback daemon - should no longer shutdown prematurely
This commit is contained in:
parent
9d385c2ef9
commit
a1eb9f7d0e
1 changed files with 8 additions and 20 deletions
|
@ -61,37 +61,25 @@ public class CallbackClientDaemon extends Thread {
|
|||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
while(!end) {
|
||||
while(!end && session.isConnected()) {
|
||||
try {
|
||||
final ClientCallback callback = session.callback(id);
|
||||
session.ack(id, callback.getMessageId());
|
||||
if (callbackExecutor.isShutdown())
|
||||
logger.fatal("Attempt to submit callback to shutdown executor");
|
||||
else
|
||||
callbackExecutor.submit(
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
client.processCallback(callback);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
logger.fatal("CallbackClientDaemon error ", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
} catch (CallbackException ex) {
|
||||
logger.fatal("Callback failed ", ex);
|
||||
}
|
||||
}
|
||||
} catch (ServerUnavailable ex) {
|
||||
session.handleServerUnavailable(ex);
|
||||
} catch(MageException ex) {
|
||||
logger.fatal("CallbackClientDaemon error ", ex);
|
||||
session.disconnect(true);
|
||||
} catch (Exception ex) {
|
||||
logger.fatal("CallbackClientDaemon failed ", ex);
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
logger.fatal("CallbackClientDaemon error ", ex);
|
||||
}
|
||||
logger.info("CallbackClientDaemon stopped");
|
||||
}
|
||||
|
||||
public void stopDaemon() {
|
||||
end = true;
|
||||
|
|
Loading…
Reference in a new issue