// If the call application is a 2-way MEP, and uses a anonymous replyTo, and the
// RM 1.1 spec level, then we must have MakeConnection enabled. We check that here,
// before we start creating a new Sequence.
if(!serverSide) {
AxisOperation op = msgContext.getAxisOperation();
int mep = WSDLConstants.MEP_CONSTANT_INVALID;
if(op != null) {
mep = op.getAxisSpecifMEPConstant();
}
if(mep == WSDLConstants.MEP_CONSTANT_OUT_IN) {
String specVersion = null;
if(rmsBean == null) {
specVersion = SequenceManager.getSpecVersion(msgContext, storageManager);
} else {
specVersion = rmsBean.getRMVersion();
}
if(specVersion == Sandesha2Constants.SPEC_VERSIONS.v1_1) {
SandeshaPolicyBean policy = SandeshaUtil.getPropertyBean(configContext.getAxisConfiguration());
if(!policy.isEnableMakeConnection()) {
String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.makeConnectionDisabled);
throw new SandeshaException(message);
}
}
}
}
//setting the reference msg store key.
if (rmsBean!=null && rmsBean.getReferenceMessageStoreKey()==null) {
//setting this application message as the reference, if it hsnt already been set.
String referenceMsgKey = SandeshaUtil.getUUID();
storageManager.storeMessageContext(referenceMsgKey, msgContext);
rmsBean.setReferenceMessageStoreKey(referenceMsgKey);
}
String outSequenceID = null;
if (rmsBean == null) {
// SENDING THE CREATE SEQUENCE.
synchronized (RMSBeanMgr.class) {
// There is a timing window where 2 sending threads can hit this point
// at the same time and both will create an RMSBean to the same endpoint
// with the same internal sequenceid
// Check that someone hasn't created the bean
rmsBean = SandeshaUtil.getRMSBeanFromInternalSequenceId(storageManager, internalSequenceId);
// if first message - setup the sending side sequence - both for the
// server and the client sides.
if (rmsBean == null) {
rmsBean = SequenceManager.setupNewClientSequence(msgContext, internalSequenceId, storageManager);
rmsBean = addCreateSequenceMessage(rmMsgCtx, rmsBean, storageManager);
}
}
} else {
outSequenceID = rmsBean.getSequenceID();
}
// the message number that was last used.
long systemMessageNumber = rmsBean.getNextMessageNumber();
// The number given by the user has to be larger than the last stored
// number.
if (givenMessageNumber > 0 && givenMessageNumber <= systemMessageNumber) {
String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.msgNumberNotLargerThanLastMsg, Long
.toString(givenMessageNumber));
throw new SandeshaException(message);
}
// Finding the correct message number.
long messageNumber = -1;
if (givenMessageNumber > 0) // if given message number is valid use it.
// (this is larger than the last stored due
// to the last check)
messageNumber = givenMessageNumber;
else if (systemMessageNumber > 0) { // if system message number is valid
// use it.
messageNumber = systemMessageNumber + 1;
} else { // This is the first message (systemMessageNumber = -1)
messageNumber = 1;
}
if (serverSide) {
// Deciding whether this is the last message. We assume it is if it relates to
// a message which arrived with the LastMessage flag on it.
RMDBean rmdBean = SandeshaUtil.getRMDBeanFromSequenceId(storageManager, inboundSequence);
// Get the last in message
String lastRequestId = rmdBean.getLastInMessageId();
RelatesTo relatesTo = msgContext.getRelatesTo();
if(relatesTo != null && lastRequestId != null &&
lastRequestId.equals(relatesTo.getValue())) {
lastMessage = true;
}
//or a constant property may call it as the last msg
Boolean inboundLast = (Boolean) msgContext.getProperty(Sandesha2Constants.MessageContextProperties.INBOUND_LAST_MESSAGE);
if (inboundLast!=null && inboundLast.booleanValue())
lastMessage = true;
}
if (lastMessage)
rmsBean.setLastOutMessage(messageNumber);
// set this as the response highest message.
rmsBean.setHighestOutMessageNumber(messageNumber);
// saving the used message number, and the expected reply count
boolean startPolling = false;
if (!dummyMessage) {
rmsBean.setNextMessageNumber(messageNumber);
// Identify the MEP associated with the message.
AxisOperation op = msgContext.getAxisOperation();
int mep = WSDLConstants.MEP_CONSTANT_INVALID;
if(op != null) {
mep = op.getAxisSpecifMEPConstant();
}
if(mep == WSDLConstants.MEP_CONSTANT_OUT_IN) {
// We only match up requests and replies when we are doing sync interactions
EndpointReference replyTo = msgContext.getReplyTo();