// 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);
if (msgContext.getTo() == null || (msgContext.getTo() != null && msgContext.getTo().isWSAddressingAnonymous())) {
if (log.isDebugEnabled())
log.debug("Rewriting anonymous EPR for LastMessage to the one stored in the RMSBean");
msgContext.setTo(rmsBean.getToEndpointReference());
}
}
// set this as the response highest message.
rmsBean.setHighestOutMessageNumber(messageNumber);
// saving the used message number
//Save the expected replies if it's not a dummy msg and it's an outIn MEP
String specVersion = SequenceManager.getSpecVersion(rmMsgCtx.getMessageContext(), storageManager);
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.getAxisSpecificMEPConstant();
}
EndpointReference replyTo = msgContext.getReplyTo();
if(mep == WSDLConstants.MEP_CONSTANT_OUT_IN){
// We only match up requests and replies when we are doing sync interactions
if (log.isDebugEnabled()) log.debug("MEP OUT_IN");
if(replyTo == null || replyTo.hasAnonymousAddress()) {
long expectedReplies = rmsBean.getExpectedReplies();
rmsBean.setExpectedReplies(expectedReplies + 1);
}
// If we support the RM anonymous URI then rewrite the ws-a anon to use the RM equivalent.
//(do should be done only for WSRM 1.1)
if (Sandesha2Constants.SPEC_VERSIONS.v1_1.equals(specVersion)) {
if (log.isDebugEnabled()) log.debug("SPEC_1_1");
String oldAddress = (replyTo == null) ? null : replyTo.getAddress();
EndpointReference newReplyTo = SandeshaUtil.rewriteEPR(rmsBean, msgContext
.getReplyTo(), configContext);
String newAddress = (newReplyTo == null) ? null : newReplyTo.getAddress();
if(newAddress != null && !newAddress.equals(oldAddress)){
msgContext.setReplyTo(newReplyTo);
}
}
}
// Set the faultTo to anonymous to make sure we get Sandesha faults back.
if(mep == WSDLConstants.MEP_CONSTANT_OUT_ONLY
|| (Sandesha2Constants.SPEC_VERSIONS.v1_0.equals(specVersion) && replyTo == null)) {
if (log.isDebugEnabled())
log.debug("Setting the faultTo to anonymous as a oneWay MEP is being used and fault msgs can then be delivered back on the backchannel");
if(msgContext.getFaultTo() == null)
msgContext.setFaultTo(new EndpointReference(AddressingConstants.Final.WSA_ANONYMOUS_URL));
}
}
boolean startPolling = false;
// We should poll for any reply-to that uses the anonymous URI, when MakeConnection
// is enabled.
if (Sandesha2Constants.SPEC_VERSIONS.v1_1.equals(specVersion)) {
SandeshaPolicyBean policy = SandeshaUtil.getPropertyBean(msgContext.getConfigurationContext().getAxisConfiguration());
if(policy.isEnableMakeConnection()) {
EndpointReference reference = rmsBean.getAcksToEndpointReference();
if(reference == null || reference.hasAnonymousAddress()) {
rmsBean.setPollingMode(true);
startPolling = true;
//ensure addressing is turned on since we require it if we want to use makeConnection
if (log.isDebugEnabled()) log.debug("Ensuring that WS-A is enabled for msg " + msgContext);
msgContext.setProperty(AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES,Boolean.FALSE);
}
}
}
if (log.isDebugEnabled()) log.debug("App msg using replyTo EPR as " + msgContext.getReplyTo() + " and faultTo EPR as " + msgContext.getFaultTo());
RelatesTo relatesTo = msgContext.getRelatesTo();
if(relatesTo != null) {
rmsBean.setHighestOutRelatesTo(relatesTo.getValue());
}
// setting async ack endpoint for the server side. (if present)
if (serverSide) {
if (rmsBean.getToEndpointReference() != null) {