"UIMAJMS_create_new_connection__FINE",
new Object[] { getAnalysisEngineController().getComponentName(), destination,
brokerConnectionURL });
}
Endpoint masterEndpoint = null;
if ( getAnalysisEngineController() instanceof AggregateAnalysisEngineController ) {
// Check if the endpoint has previously FAILED. It may have been marked as FAILED
// due to a temp queue listener shutdown caused by a Broker failure. In such case,
// before sending a message to a remote delegate we need to start a new instance
// of a listener which creates a new temp reply queue.
if ( !anEndpoint.isReplyEndpoint() ) { // this just means that we are not sending reply to a client
// The masterEndoint has the most current state. The 'anEndpoint' instance passed into
// this method is a clone from the master made at the begining of processing. The master endpoint
// may have been marked as FAILED after the clone was made
masterEndpoint = ((AggregateAnalysisEngineController) getAnalysisEngineController()).
lookUpEndpoint(anEndpoint.getDelegateKey(),false);
if ( masterEndpoint != null ) {
// Only one thread at a time is allowed here.
synchronized( masterEndpoint ) {
if ( masterEndpoint.getStatus() == Endpoint.FAILED ) {
// Returns InputChannel if the Reply Listener for the delegate has previously failed.
// If the listener hasnt failed the getReplyInputChannel returns null
InputChannel iC = getAnalysisEngineController().getReplyInputChannel(anEndpoint.getDelegateKey());
if ( iC != null ) {
try {
// Create a new Listener, new Temp Queue and associate the listener with the Input Channel
// Also resets endpoint status to OK
iC.createListener(anEndpoint.getDelegateKey(), anEndpoint);
iC.removeDelegateFromFailedList(masterEndpoint.getDelegateKey());
} catch( Exception exx) {
throw new AsynchAEException(exx);
}
} else{
throw new AsynchAEException("Aggregate:"+getAnalysisEngineController()+" Has not yet recovered a listener for delegate: "+anEndpoint.getDelegateKey());
}
} else if ( !masterEndpoint.isFreeCasEndpoint() ) {
// In case this thread blocked while the reply queue listener was created, make sure
// that this endpoint uses the most up-date reply queue destination
anEndpoint.setDestination(masterEndpoint.getDestination());
}
}
}
}
}
endpointConnection = new JmsEndpointConnection_impl(brokerConnectionEntry, anEndpoint,
getAnalysisEngineController());
brokerConnectionEntry.addEndpointConnection(key, endpointConnection);
long replyQueueInactivityTimeout = getInactivityTimeout(destination, brokerConnectionURL);
brokerConnectionEntry.getConnectionTimer().setInactivityTimeout(replyQueueInactivityTimeout);
// Connection is not in the cache, create a new connection, initialize it and cache it
if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.FINE)) {
UIMAFramework.getLogger(CLASS_NAME).logrb(Level.FINE, CLASS_NAME.getName(),
"getEndpointConnection", JmsConstants.JMS_LOG_RESOURCE_BUNDLE,
"UIMAJMS_open_new_connection_to_endpoint__FINE",
new Object[] { getDestinationName(anEndpoint), brokerConnectionURL });
}
/**
* Open connection to a broker, create JMS session and MessageProducer
*/
endpointConnection.open();
brokerConnectionEntry.getConnectionTimer().setConnectionCreationTimestamp(
endpointConnection.connectionCreationTimestamp);
if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.FINE)) {
UIMAFramework.getLogger(CLASS_NAME).logrb(
Level.FINE,
CLASS_NAME.getName(),
"getEndpointConnection",
JmsConstants.JMS_LOG_RESOURCE_BUNDLE,
"UIMAJMS_connection_opened_to_endpoint__FINE",
new Object[] { getAnalysisEngineController().getComponentName(), destination,
brokerConnectionURL });
}
} else {
if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.FINE)) {
UIMAFramework.getLogger(CLASS_NAME).logrb(
Level.FINE,
CLASS_NAME.getName(),
"getEndpointConnection",
JmsConstants.JMS_LOG_RESOURCE_BUNDLE,
"UIMAJMS_reusing_existing_connection__FINE",
new Object[] { getAnalysisEngineController().getComponentName(), destination,
brokerConnectionURL });
}
// Retrieve connection from the connection cache
endpointConnection = brokerConnectionEntry.getEndpointConnection(key);
// check the state of the connection and re-open it if necessary
if (endpointConnection != null && !endpointConnection.isOpen()) {
if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.FINE)) {
UIMAFramework.getLogger(CLASS_NAME).logrb(Level.FINE, CLASS_NAME.getName(),
"getEndpointConnection", JmsConstants.JMS_LOG_RESOURCE_BUNDLE,
"UIMAJMS_connection_closed_reopening_endpoint__FINE",
new Object[] { destination });
}
endpointConnection.open();
if ( endpointConnection.isOpen()) {
brokerConnectionEntry.getConnectionTimer()
.setConnectionCreationTimestamp(System.nanoTime());
if ( getAnalysisEngineController() instanceof AggregateAnalysisEngineController &&
anEndpoint.getDelegateKey() != null ) {
Endpoint masterEndpoint =
((AggregateAnalysisEngineController) getAnalysisEngineController()).lookUpEndpoint(
anEndpoint.getDelegateKey(), false);
masterEndpoint.setStatus(Endpoint.OK);
}
}
}
}
return endpointConnection;