return result;
}
MessageContext msgCtx = rmMsgCtx.getMessageContext();
StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(msgCtx.getConfigurationContext(),msgCtx.getConfigurationContext().getAxisConfiguration());
Sequence sequence = rmMsgCtx.getSequence();
String sequenceId = sequence.getIdentifier().getIdentifier();
long msgNo = sequence.getMessageNumber();
boolean lastMessage = sequence.getLastMessage();
// Check that both the Sequence header and message body have been secured properly
RMDBeanMgr mgr = storageManager.getRMDBeanMgr();
RMDBean bean = mgr.retrieve(sequenceId);
//check the security credentials
SandeshaUtil.assertProofOfPossession(bean, msgCtx, msgCtx.getEnvelope().getHeader().
getFirstChildWithName(new QName(rmMsgCtx.getRMNamespaceValue(), Sandesha2Constants.WSRM_COMMON.SEQUENCE)));
SandeshaUtil.assertProofOfPossession(bean, msgCtx, msgCtx.getEnvelope().getBody());
// Store the inbound sequence id, number and lastMessage onto the operation context
OperationContext opCtx = msgCtx.getOperationContext();
if(opCtx != null) {
opCtx.setProperty(Sandesha2Constants.MessageContextProperties.INBOUND_SEQUENCE_ID, sequenceId);
opCtx.setProperty(Sandesha2Constants.MessageContextProperties.INBOUND_MESSAGE_NUMBER, new Long(msgNo));
if(lastMessage) opCtx.setProperty(Sandesha2Constants.MessageContextProperties.INBOUND_LAST_MESSAGE, Boolean.TRUE);
}
// setting acked msg no range
ConfigurationContext configCtx = msgCtx.getConfigurationContext();
if (configCtx == null) {
String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.configContextNotSet);
log.debug(message);
throw new SandeshaException(message);
}
if(bean == null){
if (FaultManager.checkForUnknownSequence(rmMsgCtx, sequenceId, storageManager, false)) {
if (log.isDebugEnabled())
log.debug("Exit: SequenceProcessor::processReliableMessage, Unknown sequence");
return InvocationResponse.ABORT;
}
}
// throwing a fault if the sequence is terminated
if (FaultManager.checkForSequenceTerminated(rmMsgCtx, sequenceId, bean, false)) {
if (log.isDebugEnabled())
log.debug("Exit: SequenceProcessor::processReliableMessage, Sequence terminated");
return InvocationResponse.ABORT;
}
// throwing a fault if the sequence is closed.
if (FaultManager.checkForSequenceClosed(rmMsgCtx, sequenceId, bean, false)) {
if (log.isDebugEnabled())
log.debug("Exit: SequenceProcessor::processReliableMessage, Sequence closed");
return InvocationResponse.ABORT;
}
FaultManager.checkForLastMsgNumberExceeded(rmMsgCtx, storageManager);
if (FaultManager.checkForMessageRolledOver(rmMsgCtx, sequenceId, msgNo, bean)) {
if (log.isDebugEnabled())
log.debug("Exit: SequenceProcessor::processReliableMessage, Message rolled over " + msgNo);
return InvocationResponse.ABORT;
}
// updating the last activated time of the sequence.
bean.setLastActivatedTime(System.currentTimeMillis());
if (lastMessage) {
//setting this as the LastMessage number
bean.setLastInMessageId(msgCtx.getMessageID());
}
EndpointReference replyTo = rmMsgCtx.getReplyTo();
if (log.isDebugEnabled())
log.debug("SequenceProcessor::processReliableMessage replyTo = " + replyTo);
// Updating the server completed message ranges list
RangeString serverCompletedMessageRanges = bean.getServerCompletedMessages();
// See if the message is in the list of completed ranges
boolean msgNoPresentInList = serverCompletedMessageRanges.isMessageNumberInRanges(msgNo);
if (!msgNoPresentInList){
serverCompletedMessageRanges.addRange(new Range(msgNo));
}
// updating the Highest_In_Msg_No property which gives the highest
// message number retrieved from this sequence.
long highestInMsgNo = bean.getHighestInMessageNumber();
if (msgNo > highestInMsgNo) {
// If WS-Addressing is turned off there may not be a message id written into the SOAP
// headers, but we can still fake one up to help us match up requests and replies within
// this end of the connection.
String messageId = msgCtx.getMessageID();
if(messageId == null) {
messageId = SandeshaUtil.getUUID();
msgCtx.setMessageID(messageId);
}
bean.setHighestInMessageId(messageId);
bean.setHighestInMessageNumber(msgNo);
}
String specVersion = rmMsgCtx.getRMSpecVersion();
if ((SandeshaUtil.isDuplicateInOnlyMessage(msgCtx)
||
SandeshaUtil.isDuplicateInOutMessage(msgCtx))
&& (Sandesha2Constants.QOS.InvocationType.DEFAULT_INVOCATION_TYPE == Sandesha2Constants.QOS.InvocationType.EXACTLY_ONCE)) {
// this is a duplicate message and the invocation type is EXACTLY_ONCE. We try to return
// ack messages at this point, as if someone is sending duplicates then they may have
// missed earlier acks. We also have special processing for sync 2-way when no make connection is
// in use
if(replyTo==null || replyTo.isWSAddressingAnonymous()) {
SenderBeanMgr senderBeanMgr = storageManager.getSenderBeanMgr();
SenderBean findSenderBean = new SenderBean ();
if (rmMsgCtx.getMessageType()==Sandesha2Constants.MessageTypes.LAST_MESSAGE)
findSenderBean.setMessageType(Sandesha2Constants.MessageTypes.LAST_MESSAGE);
else
findSenderBean.setMessageType(Sandesha2Constants.MessageTypes.APPLICATION);
findSenderBean.setInboundSequenceId(sequence.getIdentifier().getIdentifier());
findSenderBean.setInboundMessageNumber(sequence.getMessageNumber());
findSenderBean.setSend(true);
SenderBean replyMessageBean = senderBeanMgr.findUnique(findSenderBean);
// this is effectively a poll for the replyMessage, so re-use the logic in the MakeConnection