if (aborting) {
return;
}
CacheEntry entry = this.getCacheEntry(aCasReferenceId);
if (entry == null) {
throw new AsynchAEException("Controller:"
+ getAnalysisEngineController().getComponentName()
+ " Unable to Send Message To Remote Endpoint: " + anEndpoint.getEndpoint()
+ " CAS:" + aCasReferenceId + " Not In The Cache");
}
// Get the connection object for a given endpoint
JmsEndpointConnection_impl endpointConnection = getEndpointConnection(anEndpoint);
if (endpointConnection == null) {
throw new AsynchAEException("Controller:"
+ getAnalysisEngineController().getComponentName()
+ " Unable to Send Message To Remote Endpoint: " + anEndpoint.getEndpoint()
+ " Connection is Invalid. InputCasReferenceId:" + anInputCasReferenceId
+ " CasReferenceId:" + aCasReferenceId + " Sequece:" + sequence);
}
if (!endpointConnection.isOpen()) {
if (!isRequest) {
return;
}
}
TextMessage tm = null;
try {
// Create empty JMS Text Message
tm = endpointConnection.produceTextMessage("");
} catch (AsynchAEException ex) {
System.out.println("UIMA AS Service:" + getAnalysisEngineController().getComponentName()
+ " Unable to Send Reply Message To Remote Endpoint: "
+ anEndpoint.getDestination() + ". Broker:" + anEndpoint.getServerURI()
+ " is Unavailable. InputCasReferenceId:" + anInputCasReferenceId
+ " CasReferenceId:" + aCasReferenceId + " Sequece:" + sequence);
UIMAFramework.getLogger(CLASS_NAME).logrb(
Level.INFO,
CLASS_NAME.getName(),
"sendCasToRemoteDelegate",
JmsConstants.JMS_LOG_RESOURCE_BUNDLE,
"UIMAJMS_unable_to_connect__INFO",
new Object[] { getAnalysisEngineController().getComponentName(),
anEndpoint.getEndpoint() });
return;
}
// Save Serialized CAS in case we need to re-send it for analysis
if (anEndpoint.isRetryEnabled()
&& getAnalysisEngineController().getInProcessCache()
.getSerializedCAS(aCasReferenceId) == null) {
getAnalysisEngineController().getInProcessCache().saveSerializedCAS(aCasReferenceId,
aSerializedCAS);
}
if (aSerializedCAS != null) {
msgSize = aSerializedCAS.length();
}
tm.setText(aSerializedCAS);
tm.setIntProperty(AsynchAEMessage.Payload, AsynchAEMessage.XMIPayload);
// Add Cas Reference Id to the outgoing JMS Header
tm.setStringProperty(AsynchAEMessage.CasReference, aCasReferenceId);
// Add common properties to the JMS Header
if (isRequest == true) {
populateHeaderWithRequestContext(tm, anEndpoint, AsynchAEMessage.Process);
} else {
populateHeaderWithResponseContext(tm, anEndpoint, AsynchAEMessage.Process);
tm.setBooleanProperty(AsynchAEMessage.SentDeltaCas, entry.sentDeltaCas());
}
// The following is true when the analytic is a CAS Multiplier
if (sequence > 0 && !isRequest) {
// Override MessageType set in the populateHeaderWithContext above.
// Make the reply message look like a request. This message will contain a new CAS
// produced by the CAS Multiplier. The client will treat this CAS
// differently from the input CAS.
tm.setIntProperty(AsynchAEMessage.MessageType, AsynchAEMessage.Request);
tm.setStringProperty(AsynchAEMessage.InputCasReference, anInputCasReferenceId);
// Add a sequence number assigned to this CAS by the controller
tm.setLongProperty(AsynchAEMessage.CasSequence, sequence);
isRequest = true;
// Add the name of the FreeCas Queue
if (freeCASTempQueue != null) {
// Attach a temp queue to the outgoing message. This a queue where
// Free CAS notifications need to be sent from the client
tm.setJMSReplyTo(freeCASTempQueue);
}
if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.FINE)) {
if (entry != null) {
UIMAFramework.getLogger(CLASS_NAME).logrb(
Level.FINE,
CLASS_NAME.getName(),
"sendCasToRemoteEndpoint",
JmsConstants.JMS_LOG_RESOURCE_BUNDLE,
"UIMAJMS_send_cas_to_collocated_service_detail__FINE",
new Object[] { getAnalysisEngineController().getComponentName(), "Remote",
anEndpoint.getEndpoint(), aCasReferenceId, anInputCasReferenceId,
entry.getInputCasReferenceId() });
}
}
}
dispatch(tm, anEndpoint, entry, isRequest, endpointConnection, msgSize);
} catch (JMSException e) {
// Unable to establish connection to the endpoint. Log it and continue
if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.INFO)) {
UIMAFramework.getLogger(CLASS_NAME).logrb(Level.INFO, CLASS_NAME.getName(),
"sendCasToRemoteDelegate", JmsConstants.JMS_LOG_RESOURCE_BUNDLE,
"UIMAJMS_unable_to_connect__INFO",
new Object[] { getAnalysisEngineController().getName(), anEndpoint.getEndpoint() });
}
}
catch (ServiceShutdownException e) {
throw e;
} catch (AsynchAEException e) {
throw e;
} catch (Exception e) {
throw new AsynchAEException(e);
}
}