try {
// loading message
request.load();
SCMPMessage scmpReq = request.getMessage();
String sessionId = scmpReq.getSessionId();
SCMPMessageSequenceNr msgSequenceNr = NettyResponderRequestHandlerTask.compositeRegistry
.getSCMPMsgSequenceNr(sessionId);
if (scmpReq.isKeepAlive()) {
scmpReq.setIsReply(true);
response.setSCMP(scmpReq);
response.write();
return;
}
if (scmpReq.isFault()) {
// fault received nothing to to return - delete largeRequest/largeResponse
this.sendBadRequestError(response, scmpReq);
NettyResponderRequestHandlerTask.compositeRegistry.removeSCMPLargeResponse(sessionId);
NettyResponderRequestHandlerTask.compositeRegistry.removeSCMPLargeRequest(sessionId);
return;
}
// needs to set a key in thread local to identify thread later and get access to the responder
ResponderRegistry responderRegistry = AppContext.getResponderRegistry();
int port = request.getLocalSocketAddress().getPort();
responderRegistry.setThreadLocal(port);
ICommand command = AppContext.getCommandFactory().getCommand(request.getKey());
// gets the command
if (command == null) {
this.sendBadRequestError(response, scmpReq);
return;
}
if (command.isPassThroughPartMsg() == false) {
// large messages needs to be handled
SCMPCompositeSender largeResponse = NettyResponderRequestHandlerTask.compositeRegistry
.getSCMPLargeResponse(sessionId);
if (largeResponse != null && scmpReq.isPart()) {
// sending of a large response has already been started and incoming scmp is a pull request
if (largeResponse.hasNext()) {
// there are still parts to send to complete request
SCMPMessage nextSCMP = largeResponse.getNext();
// handling msgSequenceNr
msgSequenceNr.incrementAndGetMsgSequenceNr();
nextSCMP.setHeader(SCMPHeaderAttributeKey.MESSAGE_SEQUENCE_NR, msgSequenceNr.getCurrentNr());
response.setSCMP(nextSCMP);
response.write();
return;
}
NettyResponderRequestHandlerTask.compositeRegistry.removeSCMPLargeResponse(sessionId);