boolean continueSending = MessageRetransmissionAdjuster.adjustRetransmittion(
rmMsgContext, senderBean, rmMsgContext.getConfigurationContext(), storageManager);
if(!continueSending) return false;
Identifier id = null;
if(messageType == Sandesha2Constants.MessageTypes.APPLICATION ||
messageType == Sandesha2Constants.MessageTypes.LAST_MESSAGE) {
String namespace = SpecSpecificConstants.getRMNamespaceValue(rmVersion);
Sequence sequence = (Sequence) rmMsgContext.getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);
if(sequence == null) {
sequence = new Sequence(namespace);
MessageNumber msgNumber = new MessageNumber(namespace);
msgNumber.setMessageNumber(senderBean.getMessageNumber());
sequence.setMessageNumber(msgNumber);
if(senderBean.isLastMessage() &&
SpecSpecificConstants.isLastMessageIndicatorRequired(rmVersion)) {
sequence.setLastMessage(new LastMessage(namespace));
}
// We just create the id here, we will add the value in later
id = new Identifier(namespace);
sequence.setIdentifier(id);
rmMsgContext.setMessagePart(Sandesha2Constants.MessageParts.SEQUENCE, sequence);
}
} else if(messageType == Sandesha2Constants.MessageTypes.TERMINATE_SEQ) {
TerminateSequence terminate = (TerminateSequence) rmMsgContext.getMessagePart(Sandesha2Constants.MessageParts.TERMINATE_SEQ);
id = terminate.getIdentifier();
} else if(messageType == Sandesha2Constants.MessageTypes.CLOSE_SEQUENCE) {
CloseSequence close = (CloseSequence) rmMsgContext.getMessagePart(Sandesha2Constants.MessageParts.CLOSE_SEQUENCE);
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 ackRequests = rmMsgContext.getMessageParts(Sandesha2Constants.MessageParts.ACK_REQUEST);
AckRequested ackRequest = (AckRequested) 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();
}