in uimaj-as-activemq/src/main/java/org/apache/uima/adapter/jms/activemq/UimaDefaultMessageListenerContainer.java [486:600]
private void handleQueueFailure(Throwable t) {
// System.out.println("............handleQueueFailure() called");
final String endpointName = (getDestination() == null) ? ""
: ((ActiveMQDestination) getDestination()).getPhysicalName();
if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.WARNING)) {
UIMAFramework.getLogger(CLASS_NAME).logrb(Level.WARNING, this.getClass().getName(),
"handleQueueFailure", JmsConstants.JMS_LOG_RESOURCE_BUNDLE,
"UIMAJMS_jms_listener_failed_WARNING",
new Object[] { endpointName, getBrokerUrl(), t });
}
boolean terminate = true;
// Check if the failure is severe enough to disable this listener. Whether or not this listener
// is actully
// disabled depends on the action associated with GetMeta Error Handler. If GetMeta Error
// Handler is
// configured to terminate the service on failure, this listener will be terminated and the
// entire service
// will be stopped.
if (disableListener(t)) {
endpoint.setReplyDestinationFailed();
// If this is a listener attached to the Aggregate Controller, use GetMeta Error
// Thresholds defined to determine what to do next after failure. Either terminate
// the service or disable the delegate with which this listener is associated with
if (controller != null && controller instanceof AggregateAnalysisEngineController) {
ErrorHandler handler = fetchGetMetaErrorHandler();
// Fetch a Map containing thresholds for GetMeta for each delegate.
Map thresholds = handler.getEndpointThresholdMap();
// Lookup delegate's key using delegate's endpoint name
String delegateKey = ((AggregateAnalysisEngineController) controller)
.lookUpDelegateKey(endpoint.getEndpoint());
// If the delegate has a threshold defined on GetMeta apply Action defined
if (delegateKey != null && thresholds.containsKey(delegateKey)) {
// Fetch the Threshold object containing error configuration
Threshold threshold = (Threshold) thresholds.get(delegateKey);
// Check if the delegate needs to be disabled
if (threshold.getAction().equalsIgnoreCase(ErrorHandler.DISABLE)) {
// The disable delegate method takes a list of delegates
List list = new ArrayList();
// Add the delegate to disable to the list
list.add(delegateKey);
try {
if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.INFO)) {
UIMAFramework.getLogger(CLASS_NAME)
.logrb(
Level.INFO,
this.getClass().getName(),
"handleQueueFailure",
UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE,
"UIMAEE_disabled_delegate_bad_broker__INFO",
new Object[] { controller.getComponentName(), delegateKey,
getBrokerUrl() });
}
// Remove the delegate from the routing table.
((AggregateAnalysisEngineController) controller).disableDelegates(list);
terminate = false; // just disable the delegate and continue
} catch (Exception e) {
if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.WARNING)) {
if ( controller != null ) {
UIMAFramework.getLogger(CLASS_NAME).logrb(Level.WARNING, CLASS_NAME.getName(),
"handleQueueFailure", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE,
"UIMAEE_service_exception_WARNING", controller.getComponentName());
}
UIMAFramework.getLogger(CLASS_NAME).logrb(Level.WARNING, CLASS_NAME.getName(),
"handleQueueFailure", JmsConstants.JMS_LOG_RESOURCE_BUNDLE,
"UIMAJMS_exception__WARNING", e);
}
terminate = true;
}
}
}
}
}
if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.WARNING)) {
UIMAFramework.getLogger(CLASS_NAME).logrb(Level.WARNING, this.getClass().getName(),
"handleQueueFailure", JmsConstants.JMS_LOG_RESOURCE_BUNDLE,
"UIMAJMS_closing_channel__WARNING",
new Object[] { getBrokerUrl(), endpoint.getEndpoint(), });
}
setRecoveryInterval(1);
// Spin a shutdown thread to terminate listener.
new Thread() {
public void run() {
try {
if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.WARNING)) {
UIMAFramework.getLogger(CLASS_NAME).logrb(Level.WARNING, this.getClass().getName(),
"handleQueueFailure.run", JmsConstants.JMS_LOG_RESOURCE_BUNDLE,
"UIMAJMS_disable_listener__WARNING",
new Object[] { endpointName, getBrokerUrl() });
}
shutdown();
} catch (Exception e) {
if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.WARNING)) {
if ( controller != null ) {
UIMAFramework.getLogger(CLASS_NAME).logrb(Level.WARNING, CLASS_NAME.getName(),
"handleQueueFailure.run", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE,
"UIMAEE_service_exception_WARNING", controller.getComponentName());
}
UIMAFramework.getLogger(CLASS_NAME).logrb(Level.WARNING, CLASS_NAME.getName(),
"handleQueueFailure.run", JmsConstants.JMS_LOG_RESOURCE_BUNDLE,
"UIMAJMS_exception__WARNING", e);
}
}
}
}.start();
if (terminate) {
terminate(t);
}
}