in uimaj-as-jms/src/main/java/org/apache/uima/adapter/jms/client/BaseUIMAAsynchronousEngineCommon_impl.java [1660:1735]
protected void handleException(Exception exception, String casReferenceId, String inputCasReferenceId, ClientRequest cachedRequest, boolean doNotify, boolean rethrow)
throws Exception {
if (!isShutdownException(exception)) {
clientSideJmxStats.incrementProcessErrorCount();
}
if (exception != null && cachedRequest != null) {
cachedRequest.setException(exception);
cachedRequest.setProcessException();
}
cpcReadySemaphore.release();
if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.INFO)) {
UIMAFramework.getLogger(CLASS_NAME).logrb(
Level.INFO,
CLASS_NAME.getName(),
"handleException",
JmsConstants.JMS_LOG_RESOURCE_BUNDLE,
"UIMAJMS_received_exception_msg_INFO",
new Object[] { serviceDelegate.getComponentName(),
getBrokerURI(),
casReferenceId, exception });
}
try {
if (doNotify) {
ProcessTrace pt = new ProcessTrace_impl();
// HACK! Service should only send exceptions for CASes that we sent.
// Check if this or its input parent is known.
if (inputCasReferenceId != null) {
serviceDelegate.removeCasFromOutstandingList(inputCasReferenceId);
} else if (casReferenceId != null ) {
serviceDelegate.removeCasFromOutstandingList(casReferenceId);
}
UimaASProcessStatusImpl status;
if (cachedRequest != null ) {
// Add Cas referenceId(s) to enable matching replies with requests (ids may be null)
status = new UimaASProcessStatusImpl(pt, cachedRequest.getCAS(), casReferenceId,
inputCasReferenceId);
} else {
status = new UimaASProcessStatusImpl(pt, null, casReferenceId,
inputCasReferenceId);
}
status.addEventStatus("Process", "Failed", exception);
if (cachedRequest != null && !cachedRequest.isSynchronousInvocation()
&& cachedRequest.getCAS() != null) {
notifyListeners(cachedRequest.getCAS(), status, AsynchAEMessage.Process);
} else {
notifyListeners(null, status, AsynchAEMessage.Process);
}
// Done here
return;
} else {
if ( rethrow ) {
throw new ResourceProcessException(exception);
}
}
} catch (Exception e) {
throw e;
} finally {
if (cachedRequest != null) {
if (cachedRequest.isSynchronousInvocation() && cachedRequest.isProcessException()) {
// Wake up the send thread that is blocking waiting for a reply. When the thread
// receives the signal, it checks if the reply contains an exception and will
// not return control back to the client
wakeUpSendThread(cachedRequest);
}
// Dont release the CAS if the application uses synchronous API
if (!cachedRequest.isSynchronousInvocation() && cachedRequest.getCAS() != null) {
cachedRequest.getCAS().release();
}
}
removeFromCache(casReferenceId);
serviceDelegate.removeCasFromOutstandingList(casReferenceId);
decrementOutstandingCasCounter();
}
}