ConfigurationContext context = terminateSeqMsg.getConfigurationContext();
StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(context,context.getAxisConfiguration());
// Check that the sender of this TerminateSequence holds the correct token
RMSequenceBean rmBean = SandeshaUtil.getRMDBeanFromSequenceId(storageManager, sequenceId);
if(rmBean==null){
rmBean = SandeshaUtil.getRMSBeanFromSequenceId(storageManager, sequenceId);
}
//check security credentials
SandeshaUtil.assertProofOfPossession(rmBean, terminateSeqMsg,
terminateSeqMsg.getEnvelope().getBody());
if (FaultManager.checkForUnknownSequence(terminateSeqRMMsg, sequenceId, storageManager, false)) {
if (log.isDebugEnabled())
log.debug("Exit: TerminateSeqMsgProcessor::processInMessage, unknown sequence");
return false;
}
// add the terminate sequence response if required.
RMMsgContext terminateSequenceResponse = null;
if (SpecSpecificConstants.isTerminateSequenceResponseRequired(terminateSeqRMMsg.getRMSpecVersion()))
terminateSequenceResponse = getTerminateSequenceResponse(terminateSeqRMMsg, rmBean, sequenceId, storageManager);
setUpHighestMsgNumbers(context, storageManager, sequenceId, terminateSeqRMMsg);
boolean inOrderInvocation = SandeshaUtil.getDefaultPropertyBean(context.getAxisConfiguration()).isInOrder();
//if the invocation is inOrder and if this is RM 1.1 there is a posibility of all the messages having aleady being invoked.
//In this case we should do the full termination.
boolean doFullTermination = false;
if (inOrderInvocation && rmBean instanceof RMDBean) {
long highestMsgNo = ((RMDBean)rmBean).getHighestInMessageNumber();
long nextMsgToProcess = ((RMDBean)rmBean).getNextMsgNoToProcess();
if (nextMsgToProcess>highestMsgNo) {
//all the messages have been invoked, u can do the full termination
doFullTermination = true;
}
} else {
//for not-inorder case, always do the full termination.
doFullTermination = true;
}
if (doFullTermination) {
TerminateManager.cleanReceivingSideAfterInvocation(sequenceId, storageManager);
TerminateManager.cleanReceivingSideOnTerminateMessage(context, sequenceId, storageManager);
} else
TerminateManager.cleanReceivingSideOnTerminateMessage(context, sequenceId, storageManager);
rmBean.setTerminated(true);
rmBean.setLastActivatedTime(System.currentTimeMillis());
if(rmBean instanceof RMDBean){
storageManager.getRMDBeanMgr().update((RMDBean)rmBean);
}
else{
storageManager.getRMSBeanMgr().update((RMSBean)rmBean);