in uimaj-as-jms/src/main/java/org/apache/uima/adapter/jms/client/ClientServiceDelegate.java [102:226]
public void handleError(Exception e, ErrorContext errorContext) {
String casReferenceId = null;
CAS cas = null;
ClientRequest cachedRequest = null;
casReferenceId = (String) errorContext.get(AsynchAEMessage.CasReference);
synchronized(errorMux) {
if (!clientUimaAsEngine.running) {
cancelDelegateTimer();
return;
}
int command = ((Integer) errorContext.get(AsynchAEMessage.Command)).intValue();
try {
if (e instanceof MessageTimeoutException) {
switch (command) {
case AsynchAEMessage.Process:
//casReferenceId = (String) errorContext.get(AsynchAEMessage.CasReference);
if (casReferenceId != null) {
cachedRequest = (ClientRequest) clientUimaAsEngine.clientCache.get(casReferenceId);
if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.WARNING)
&& getEndpoint() != null) {
UIMAFramework.getLogger(CLASS_NAME).logrb(Level.WARNING, getClass().getName(),
"handleError", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE,
"UIMAJMS_process_timeout_WARNING",
new Object[] { getEndpoint().getEndpoint(), clientUimaAsEngine.getBrokerURI(), cachedRequest.getHostIpProcessingCAS() });
}
if (cachedRequest != null && cachedRequest.isRemote()) {
cas = cachedRequest.getCAS();
}
boolean isPingTimeout = false;
if (errorContext.containsKey(AsynchAEMessage.ErrorCause)) {
isPingTimeout = AsynchAEMessage.PingTimeout == (Integer) errorContext
.get(AsynchAEMessage.ErrorCause);
}
if (isPingTimeout && isAwaitingPingReply()) {
// reset only if the connection is valid
if ( clientUimaAsEngine.state != ClientState.RECONNECTING) {
resetAwaitingPingReply();
}
pingTimeout = true;
UIMAFramework.getLogger(CLASS_NAME).logrb(Level.WARNING, CLASS_NAME.getName(),
"handleError", JmsConstants.JMS_LOG_RESOURCE_BUNDLE,
"UIMAJMS_client_ping_timed_out__WARNING", new Object[] { getKey() });
clientUimaAsEngine.notifyOnTimout(cas, clientUimaAsEngine.getEndPointName(),
BaseUIMAAsynchronousEngineCommon_impl.ProcessTimeout, casReferenceId);
} else {
if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.WARNING)) {
UIMAFramework.getLogger(CLASS_NAME).logrb(Level.WARNING, CLASS_NAME.getName(),
"handleError", JmsConstants.JMS_LOG_RESOURCE_BUNDLE,
"UIMAJMS_client_process_timeout__WARNING", new Object[] { super.getCasProcessTimeout() });
}
clientUimaAsEngine.notifyOnTimout(cas, clientUimaAsEngine.getEndPointName(),
BaseUIMAAsynchronousEngineCommon_impl.ProcessTimeout, casReferenceId);
}
}
clientUimaAsEngine.clientSideJmxStats.incrementProcessTimeoutErrorCount();
break;
case AsynchAEMessage.GetMeta:
if (isAwaitingPingReply()) {
if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.WARNING)) {
UIMAFramework.getLogger(CLASS_NAME).logrb(Level.WARNING, CLASS_NAME.getName(),
"handleError", JmsConstants.JMS_LOG_RESOURCE_BUNDLE,
"UIMAJMS_client_ping_timed_out__WARNING", new Object[] { clientUimaAsEngine.getEndPointName(),getCasPendingDispatchListSize(),getCasPendingReplyListSize()});
}
super.resetAwaitingPingReply();
synchronized( super.pendingDispatchList ) {
// Fail all CASes in the PendingDispatch list
Iterator<Delegate.DelegateEntry> it = getDelegateCasesPendingDispatch().iterator();
while( clientUimaAsEngine.running && it.hasNext() ) {
DelegateEntry de = it.next();
cachedRequest = (ClientRequest) (clientUimaAsEngine.getCache()).get(de.getCasReferenceId());
if ( cachedRequest != null ) {
if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.WARNING)) {
UIMAFramework.getLogger(CLASS_NAME).logrb(Level.WARNING, CLASS_NAME.getName(),
"handleError", JmsConstants.JMS_LOG_RESOURCE_BUNDLE,
"UIMAJMS_client_reject_by_forced_timeout__WARNING", new Object[] { de.getCasReferenceId(), String.valueOf(cachedRequest.getCAS().hashCode())});
}
//dumpDelayedList();
try {
clientUimaAsEngine.handleException(new UimaASProcessCasTimeout("Service Not Responding to Ping - CAS:"+de.getCasReferenceId(), new UimaASPingTimeout("Forced Timeout on CAS in PendingDispatch list. The CAS Has Not Been Dispatched since the Service Appears to be Unavailable")), de.getCasReferenceId(), null,cachedRequest, !cachedRequest.isSynchronousInvocation(), false);
} catch( Exception ex) {
//ex.printStackTrace();
}
}
if ( clientUimaAsEngine.running ) {
it.remove();
}
}
}
} else {
if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.WARNING)) {
UIMAFramework.getLogger(CLASS_NAME).logrb(Level.WARNING, CLASS_NAME.getName(),
"handleError", JmsConstants.JMS_LOG_RESOURCE_BUNDLE,
"UIMAJMS_meta_timeout_WARNING", new Object[] { getKey() });
}
// Notifies Listeners and removes ClientRequest instance from the client cache
clientUimaAsEngine.notifyOnTimout(cas, clientUimaAsEngine.getEndPointName(),
BaseUIMAAsynchronousEngineCommon_impl.MetadataTimeout, casReferenceId);
clientUimaAsEngine.clientSideJmxStats.incrementMetaTimeoutErrorCount();
}
break;
case AsynchAEMessage.CollectionProcessComplete:
break;
}
}
} catch (Exception ex) {
if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.WARNING)) {
UIMAFramework.getLogger(CLASS_NAME).logrb(Level.WARNING, getClass().getName(),
"handleError", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE,
"UIMAEE_exception__WARNING", ex);
}
}
// Dont release the CAS if synchronous API was used
if (cas != null && !cachedRequest.isSynchronousInvocation()) {
cas.release();
}
}
}