public void receive(Exception ex) {
SCMPMessage reqMessage = this.request.getMessage();
String sid = reqMessage.getSessionId();
LOGGER.warn("receive exception sid=" + sid + " " + ex.toString());
String serviceName = reqMessage.getServiceName();
IStatefulServer server = this.cascSubscription.getServer();
SCMPVersion scmpVersion = reqMessage.getSCMPVersion();
if (reqMessage.getHeader(SCMPHeaderAttributeKey.CASCADED_MASK) == null) {
// free server from subscription if cascaded SC unsubscribes himself
server.removeSession(this.cascSubscription);
}
SCMPMessage fault = null;
if (ex instanceof IdleTimeoutException) {
// operation timeout handling - SCMP Version request
fault = new SCMPMessageFault(scmpVersion, SCMPError.OPERATION_TIMEOUT,
"Operation timeout expired on SC csc unsubscribe sid=" + sid);
} else if (ex instanceof IOException) {
fault = new SCMPMessageFault(scmpVersion, SCMPError.CONNECTION_EXCEPTION,
"broken connection on SC csc unsubscribe sid=" + sid);
} else if (ex instanceof InvalidMaskLengthException) {
fault = new SCMPMessageFault(scmpVersion, SCMPError.HV_WRONG_MASK, ex.getMessage() + " sid=" + sid);
} else {
fault = new SCMPMessageFault(scmpVersion, SCMPError.SC_ERROR, "executing csc unsubscribe failed sid=" + sid);
}
// forward server reply to client
fault.setIsReply(true);
fault.setServiceName(serviceName);
fault.setMessageType(SCMPMsgType.CSC_UNSUBSCRIBE);
this.response.setSCMP(fault);
this.responderCallback.responseCallback(request, response);
// delete subscription failed abort!
server.abortSession(this.cascSubscription, "unsubscribe failed, exception received in callback");
}