// This CAS came in from the CAS Multiplier. Treat it differently than the
// input CAS. First, in case the Aggregate needs to send this CAS to the
// client, retrieve the client destination by looking up the client endpoint
// using input CAS reference id. CASes generated by the CAS multiplier will have
// the same Cas Reference id.
Endpoint replyToEndpoint = inputCasCacheEntry.getMessageOrigin();
if ( getController() instanceof AggregateAnalysisEngineController )
{
newCASProducedBy = inputCasCacheEntry.getCasMultiplierKey();
// increment number of subordinate CASes that are currently being processed
// The input CAS (parent) will be held by the aggregate until all of its
// subordinate CASes are fully processed. Only then, the aggregate can return
// it back to the client
synchronized( inputCasCacheEntry )
{
inputCasCacheEntry.incrementSubordinateCasInPlayCount();
}
if ( ((AggregateAnalysisEngineController)getController()).sendRequestToReleaseCas() )
{
try
{
// Change the name of the queue where the request to free a CAS will be sent.
aMessageContext.getEndpoint().setEndpoint(aMessageContext.getEndpoint().getEndpoint()+"CasSync");
getController().getOutputChannel().sendRequest(AsynchAEMessage.ReleaseCAS, casReferenceId, aMessageContext.getEndpoint());
requestToFreeCasSent = true;
}
catch( Exception e){}
}
}
// MessageContext contains endpoint set by the CAS Multiplier service. Overwrite
// this with the endpoint of the client who sent the input CAS. In case this
// aggregate is configured to send new CASes to the client we know where to send them.
aMessageContext.getEndpoint().setEndpoint(replyToEndpoint.getEndpoint());
aMessageContext.getEndpoint().setServerURI(replyToEndpoint.getServerURI());
// Set this to null so that the new CAS gets its own Cas Reference Id below
casReferenceId = null;
}
else if ( getController().isTopLevelComponent())
{
Endpoint replyToEndpoint = aMessageContext.getEndpoint();
if ( getController() instanceof AggregateAnalysisEngineController )
{
((AggregateAnalysisEngineController)getController()).addMessageOrigin(casReferenceId, replyToEndpoint);
}