// 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
// processor. This will use this thread to re-send the reply, writing it into the transport.
// As the reply is now written we do not want to continue processing, or suspend, so we abort.
if(replyMessageBean != null) {
if(log.isDebugEnabled()) log.debug("Found matching reply for replayed message");
MakeConnectionProcessor.replyToPoll(rmMsgCtx, replyMessageBean, storageManager, false, null, transaction);
result = InvocationResponse.ABORT;
if (log.isDebugEnabled())
log.debug("Exit: SequenceProcessor::processReliableMessage, replayed message: " + result);
return result;
}
}
EndpointReference acksTo = bean.getAcksToEndpointReference();
//Send an Ack if needed.
//We are not sending acks for duplicate messages in the anon InOut case.
//If a standalone ack get sent before the actualy message (I.e. before the original msg get
//replied), the client may take this as a InOnly message and may avoid looking for the application
//response if using replay.
//Therefore we only send acks back in the anon InOnly case.
int msgExchangePattern = rmMsgCtx.getMessageContext().getAxisOperation().getAxisSpecificMEPConstant();
if (log.isDebugEnabled())
log.debug("SequenceProcessor:: mep= " + msgExchangePattern);
if (WSDLConstants.MEP_CONSTANT_IN_ONLY == msgExchangePattern &&
(replyTo==null || replyTo.getAddress()==null || replyTo.isWSAddressingAnonymous() || replyTo.hasNoneAddress())) {
sendAckIfNeeded(bean, sequenceId, rmMsgCtx, storageManager, true, acksTo.hasAnonymousAddress());
}
result = InvocationResponse.ABORT;
if (log.isDebugEnabled())
log.debug("Exit: SequenceProcessor::processReliableMessage, dropping duplicate: " + result);
return result;
}
// If the message is a reply to an outbound message then we can update the RMSBean that
// matches.
EndpointReference toEPR = msgCtx.getTo();
if(toEPR == null || toEPR.hasAnonymousAddress()) {
RMSBean outBean = null;
// Look for the correct outbound sequence by checking the anon uuid (if there is one)
String toAddress = (toEPR == null) ? null : toEPR.getAddress();
if(SandeshaUtil.isWSRMAnonymous(toAddress)) {
RMSBean finderBean = new RMSBean();
finderBean.setAnonymousUUID(toAddress);
outBean = storageManager.getRMSBeanMgr().findUnique(finderBean);
}
// Fall back to the sequence that may have been offered at sequence creation time
if(outBean == null) {
String outboundSequence = bean.getOutboundInternalSequence();
if(outboundSequence != null) {
outBean = SandeshaUtil.getRMSBeanFromInternalSequenceId(storageManager, outboundSequence);
}
}
// Update the reply count
if(outBean != null && outBean.getExpectedReplies() > 0 ) {
outBean.setExpectedReplies(outBean.getExpectedReplies() - 1);
RMSBeanMgr outMgr = storageManager.getRMSBeanMgr();
outMgr.update(outBean);
}
}
// Set the last activated time
bean.setLastActivatedTime(System.currentTimeMillis());
// Update the RMD bean
mgr.update(bean);
// If we are doing sync 2-way over WSRM 1.0, then we may just have received one of
// the reply messages that we were looking for. If so we can remove the matching sender bean.
int mep = msgCtx.getAxisOperation().getAxisSpecificMEPConstant();
if(specVersion!=null && specVersion.equals(Sandesha2Constants.SPEC_VERSIONS.v1_0) &&
mep == WSDLConstants.MEP_CONSTANT_OUT_IN) {
RelatesTo relatesTo = msgCtx.getRelatesTo();
if(relatesTo != null) {
String messageId = relatesTo.getValue();
SenderBean sender = storageManager.getSenderBeanMgr().retrieve(messageId);
if(sender != null) {
if(log.isDebugEnabled()) log.debug("Deleting sender for sync-2-way message");
storageManager.removeMessageContext(sender.getMessageContextRefKey());
//this causes the request to be deleted even without an ack.
storageManager.getSenderBeanMgr().delete(messageId);
// Try and terminate the corresponding outbound sequence
RMSBean rmsBean = SandeshaUtil.getRMSBeanFromSequenceId(storageManager, sender.getSequenceID());
TerminateManager.checkAndTerminate(rmMsgCtx.getConfigurationContext(), storageManager, rmsBean);
}
}
}