in uimaj-as-activemq/src/main/java/org/apache/uima/adapter/jms/activemq/JmsOutputChannel.java [941:1031]
public void sendReply(Throwable t, String aCasReferenceId, String aParentCasReferenceId,
Endpoint anEndpoint, int aCommand) throws AsynchAEException {
anEndpoint.setReplyEndpoint(true);
try {
Throwable wrapper = null;
if (!(t instanceof UimaEEServiceException)) {
// Strip off AsyncAEException and replace with UimaEEServiceException
if (t instanceof AsynchAEException && t.getCause() != null) {
wrapper = new UimaEEServiceException(t.getCause());
} else {
wrapper = new UimaEEServiceException(t);
}
}
if (aborting) {
return;
}
anEndpoint.setReplyEndpoint(true);
JmsEndpointConnection_impl endpointConnection = getEndpointConnection(anEndpoint);
// Create Message that will contain serialized Exception with stack
ObjectMessage om = endpointConnection.produceObjectMessage();
// Now try to catch non-serializable exception. The Throwable passed into this method may
// not be serializable. Catch the exception, and create a wrapper containing stringified
// stack trace.
try {
// serialize the Throwable
if (wrapper == null) {
om.setObject(t);
} else {
om.setObject(wrapper);
}
} catch( RuntimeException e) {
// Check if we failed due to non-serializable object in the Throwable
if ( e.getCause() != null && e.getCause() instanceof NotSerializableException ) {
// stringify the stack trace
StringWriter sw = new StringWriter();
t.printStackTrace(new PrintWriter(sw));
wrapper = new UimaEEServiceException(sw.toString());
// serialize the new wrapper
om.setObject(wrapper);
} else {
throw e; // rethrow
}
} catch( Exception e) {
throw e; // rethrow
}
// Add common header properties
populateHeaderWithResponseContext(om, anEndpoint, aCommand); // AsynchAEMessage.Process);
om.setIntProperty(AsynchAEMessage.Payload, AsynchAEMessage.Exception);
if (aCasReferenceId != null) {
om.setStringProperty(AsynchAEMessage.CasReference, aCasReferenceId);
if (aParentCasReferenceId != null) {
om.setStringProperty(AsynchAEMessage.InputCasReference, aParentCasReferenceId);
}
}
if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.FINE)) {
UIMAFramework.getLogger(CLASS_NAME).logrb(Level.FINE, CLASS_NAME.getName(), "sendReply",
JmsConstants.JMS_LOG_RESOURCE_BUNDLE, "UIMAJMS_sending_exception__FINE",
new Object[] { getAnalysisEngineController().getName(), anEndpoint.getEndpoint() });
}
// Dispatch Message to destination
endpointConnection.send(om, 0, false);
addIdleTime(om);
} catch (JMSException e) {
// Unable to establish connection to the endpoint. Logit and continue
if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.INFO)) {
UIMAFramework.getLogger(CLASS_NAME).logrb(Level.INFO, CLASS_NAME.getName(), "sendReply",
JmsConstants.JMS_LOG_RESOURCE_BUNDLE, "UIMAJMS_unable_to_connect__INFO",
new Object[] { getAnalysisEngineController().getName(), anEndpoint.getEndpoint() });
}
} catch (ServiceShutdownException e) {
if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.WARNING)) {
UIMAFramework.getLogger(CLASS_NAME).logrb(Level.WARNING, CLASS_NAME.getName(),
"sendReply", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE,
"UIMAEE_service_exception_WARNING", getAnalysisEngineController().getComponentName());
UIMAFramework.getLogger(CLASS_NAME).logrb(Level.WARNING, CLASS_NAME.getName(),
"sendReply", JmsConstants.JMS_LOG_RESOURCE_BUNDLE,
"UIMAJMS_exception__WARNING", e);
}
} catch (AsynchAEException e) {
if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.INFO)) {
UIMAFramework.getLogger(CLASS_NAME).logrb(Level.INFO, CLASS_NAME.getName(), "sendReply",
JmsConstants.JMS_LOG_RESOURCE_BUNDLE, "UIMAJMS_unable_to_connect__INFO",
new Object[] { getAnalysisEngineController().getName(), anEndpoint.getEndpoint() });
}
} catch (Exception e) {
throw new AsynchAEException(e);
}
}