}
private void sendCasToRemoteEndpoint(boolean isRequest, String aSerializedCAS, CacheEntry entry,
Endpoint anEndpoint, boolean startTimer) throws AsynchAEException,
ServiceShutdownException {
CasStateEntry casStateEntry = null;
long msgSize = 0;
try {
if (aborting) {
return;
}
casStateEntry = getAnalysisEngineController().getLocalCache().lookupEntry(
entry.getCasReferenceId());
// Get the connection object for a given endpoint
JmsEndpointConnection_impl endpointConnection = getEndpointConnection(anEndpoint);
if (!endpointConnection.isOpen()) {
if (!isRequest) {
return;
}
}
// Create empty JMS Text Message
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. CasReferenceId:" + casStateEntry.getCasReferenceId());
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(
entry.getCasReferenceId()) == null) {
getAnalysisEngineController().getInProcessCache().saveSerializedCAS(
entry.getCasReferenceId(), 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, entry.getCasReferenceId());
// 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 (casStateEntry.isSubordinate() && !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);