String serviceName = reqMessage.getServiceName();
int oti = reqMessage.getHeaderInt(SCMPHeaderAttributeKey.OPERATION_TIMEOUT);
// check service is present
Service abstractService = this.getService(serviceName);
SCCacheManager cacheManager = AppContext.getCacheManager();
switch (abstractService.getType()) {
case CASCADED_SESSION_SERVICE:
if (cacheManager.isCacheEnabled()) {
// try to load response from cache
SCMPMessage message = cacheManager.tryGetMessageFromCacheOrLoad(reqMessage);
if (message != null) {
// message found in cache - hand it to the client
response.setSCMP(message);
responderCallback.responseCallback(request, response);
return;
}
}
this.executeCascadedService(request, response, responderCallback);
return;
default:
// code for other types of services is below
break;
}
int otiOnSCMillis = (int) (oti * basicConf.getOperationTimeoutMultiplier());
String sessionId = reqMessage.getSessionId();
Session session = this.getSessionById(sessionId);
if (session.hasPendingRequest() == true) {
LOGGER.warn("session " + sessionId + " has pending request");
SCMPCommandException scmpCommandException = new SCMPCommandException(SCMPError.PARALLEL_REQUEST, "service="
+ reqMessage.getServiceName() + " sid=" + sessionId);
scmpCommandException.setMessageType(this.getKey());
throw scmpCommandException;
}
// sets the time of last execution
session.resetExecuteTime();
synchronized (session) {
session.setPendingRequest(true); // IMPORTANT - set true before reset timeout - because of parallel echo call
// reset session timeout to OTI+ECI - during wait for server reply
this.sessionRegistry.resetSessionTimeout(session, (otiOnSCMillis + session.getSessionTimeoutMillis()));
}
if (cacheManager.isCacheEnabled()) {
try {
// try to load response from cache
SCMPMessage message = cacheManager.tryGetMessageFromCacheOrLoad(reqMessage);
if (message != null) {
synchronized (session) {
// reset session timeout to ECI
this.sessionRegistry.resetSessionTimeout(session, session.getSessionTimeoutMillis());
session.setPendingRequest(false); // IMPORTANT - set false after reset timeout - parallel echo call