boolean continueSending = MessageRetransmissionAdjuster.adjustRetransmittion(
rmMsgContext, senderBean, rmMsgContext.getConfigurationContext(), storageManager);
if(!continueSending) return null;
Identifier id = null;
if(messageType == Sandesha2Constants.MessageTypes.APPLICATION ||
messageType == Sandesha2Constants.MessageTypes.LAST_MESSAGE) {
String namespace = SpecSpecificConstants.getRMNamespaceValue(rmVersion);
Sequence sequence = rmMsgContext.getSequence();
if(sequence == null) {
sequence = new Sequence(namespace);
sequence.setMessageNumber(senderBean.getMessageNumber());
if(senderBean.isLastMessage() &&
SpecSpecificConstants.isLastMessageIndicatorRequired(rmVersion)) {
sequence.setLastMessage(true);
}
// We just create the id here, we will add the value in later
id = new Identifier(namespace);
sequence.setIdentifier(id);
rmMsgContext.setSequence(sequence);
}
} else if(messageType == Sandesha2Constants.MessageTypes.TERMINATE_SEQ) {
TerminateSequence terminate = rmMsgContext.getTerminateSequence();
id = terminate.getIdentifier();
} else if(messageType == Sandesha2Constants.MessageTypes.CLOSE_SEQUENCE) {
CloseSequence close = rmMsgContext.getCloseSequence();
id = close.getIdentifier();
} else if(messageType == Sandesha2Constants.MessageTypes.ACK_REQUEST) {
// The only time that we can have a message of this type is when we are sending a
// stand-alone ack request, and in that case we only expect to find a single ack
// request header in the message.
Iterator<AckRequested> ackRequests = rmMsgContext.getAckRequests();
AckRequested ackRequest = ackRequests.next();
if (ackRequests.hasNext()) {
throw new SandeshaException (SandeshaMessageHelper.getMessage(SandeshaMessageKeys.ackRequestMultipleParts));
}
id = ackRequest.getIdentifier();
}
// TODO consider adding an extra ack request, as we are about to send the message and we
// know which sequence it is associated with.
if(id != null && !senderBean.getSequenceID().equals(id.getIdentifier())) {
id.setIndentifer(senderBean.getSequenceID());
// Write the changes back into the message context
rmMsgContext.addSOAPEnvelope();
} else if(rmMsgContext.getProperty(RMMsgCreator.ACK_TO_BE_WRITTEN) != null){
rmMsgContext.addSOAPEnvelope();