public void run() {
if ( delegateEntry.usesDedicatedTimerThread) {
delegateEntry.getDelegateTimer().cancel();
}
ErrorContext errorContext = new ErrorContext();
errorContext.add(AsynchAEMessage.Command, aCommand);
String enrichedMessage = enrichProcessCASTimeoutMessage(aCommand, aCasReferenceId,timeToWait,"Delegate Service:"+delegateKey+" Has Timed Out While Processing CAS:"+aCasReferenceId );
Exception cause = new MessageTimeoutException(enrichedMessage);
if (AsynchAEMessage.Process == aCommand) {
if ( delegate.getMetaReceiptTime() == 0 || ( (delegate.getMetaReceiptTime() + timeToWait) < System.currentTimeMillis() )) {
delegate.setState(TIMEOUT_STATE);
}
if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.WARNING)) {
UIMAFramework.getLogger(CLASS_NAME).logrb(Level.WARNING, this.getClass().getName(),
"Delegate.TimerTask.run", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE,
"UIMAEE_cas_timeout_no_reply__WARNING",
new Object[] { delegate.getKey(), timeToWait, aCasReferenceId });
}
errorContext.add(AsynchAEMessage.CasReference, aCasReferenceId);
errorContext.add(ErrorContext.THROWABLE_ERROR, cause);
/* 4/24/ Commented out. There is a dedicated timer for Ping timeouts
// Check if this is a Ping timeout and associate this with
// the oldest CAS from the list of CASes pending reply.
if (isAwaitingPingReply() && getCasPendingReplyListSize() > 0) {
String casReferenceId = getOldestCasIdFromOutstandingList();
errorContext.add(AsynchAEMessage.CasReference, casReferenceId);
// Override the command to make sure this timeout is handled
// by the ProcessCasErrorHandler.
errorContext.add(AsynchAEMessage.Command, AsynchAEMessage.Process);
errorContext.add(AsynchAEMessage.ErrorCause, AsynchAEMessage.PingTimeout);
}
*/
} else if (AsynchAEMessage.GetMeta == aCommand) {
delegate.setState(TIMEOUT_STATE);
if ( aCasReferenceId != null ) { // true on GetMeta Ping timeout
errorContext.add(AsynchAEMessage.CasReference, aCasReferenceId);
errorContext.add(AsynchAEMessage.ErrorCause, AsynchAEMessage.PingTimeout);
}
if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.WARNING)) {
UIMAFramework.getLogger(CLASS_NAME).logrb(Level.WARNING, this.getClass().getName(),
"Delegate.TimerTask.run", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE,
"UIMAEE_meta_timeout_no_reply__WARNING",
new Object[] { delegate.getKey(), timeToWait });
}
} else if (AsynchAEMessage.CollectionProcessComplete == aCommand) {
delegate.setState(TIMEOUT_STATE);
if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.WARNING)) {
UIMAFramework.getLogger(CLASS_NAME).logrb(Level.WARNING, this.getClass().getName(),
"Delegate.TimerTask.run", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE,
"UIMAEE_cpc_timeout_no_reply__WARNING",
new Object[] { delegate.getKey(), timeToWait });
}
} else {
delegate.setState(TIMEOUT_STATE);
}
errorContext.add(AsynchAEMessage.Endpoint, getEndpoint());
handleError(cause, errorContext);
}
}, timeToRun);
if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.FINE)) {
UIMAFramework.getLogger(CLASS_NAME).logrb(Level.FINE, this.getClass().getName(),