options.setProperty(Sandesha2Constants.MessageContextProperties.INTERNAL_SEQUENCE_ID, internalSequenceID);
options.setProperty(SandeshaClientConstants.RM_SPEC_VERSION, oldRMSBean.getRMVersion());
options.setProperty(AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES, Boolean.FALSE);
//Update the RMSBean so as to mark it as reallocated if it isn't an RMSbean created for a previous reallocation
RMSBean originallyReallocatedRMSBean = SandeshaUtil.isLinkedToReallocatedRMSBean(storageManager, oldRMSBean.getInternalSequenceID());
if(originallyReallocatedRMSBean == null){
oldRMSBean.setReallocated(Sandesha2Constants.WSRM_COMMON.REALLOCATED);
storageManager.getRMSBeanMgr().update(oldRMSBean);
} else {
options.setProperty(Sandesha2Constants.MessageContextProperties.INTERNAL_SEQUENCE_ID, originallyReallocatedRMSBean.getInternalSequenceID());
originallyReallocatedRMSBean.setInternalSeqIDOfSeqUsedForReallocation(null);
storageManager.getRMSBeanMgr().update(originallyReallocatedRMSBean);
//Setting this property so that the bean can be deleted
oldRMSBean.setReallocated(Sandesha2Constants.WSRM_COMMON.ORIGINAL_REALLOCATED_BEAN_COMPLETE);
oldRMSBean.setInternalSeqIDOfSeqUsedForReallocation(originallyReallocatedRMSBean.getInternalSequenceID());
storageManager.getRMSBeanMgr().update(oldRMSBean);
}
//Commit current transaction that wraps the manageFaultMsg as we are about to start
//resending msgs on a new seq and they will need to get a transaction on the
//current thread
if(transaction != null && transaction.isActive()) transaction.commit();
//send the msgs - this will setup a new sequence to the same endpoint
Iterator<MessageContext> it = msgsToSend.iterator();
while(it.hasNext()){
MessageContext msgCtx = (MessageContext)it.next();
//Set the action
client.getOptions().setAction(msgCtx.getWSAAction());
//Set the message ID
client.getOptions().setMessageId(msgCtx.getMessageID());
//Get the AxisOperation
AxisOperation axisOperation = msgCtx.getAxisOperation();
//If it's oneway or async, reallocate
EndpointReference replyTo = oldRMSBean.getReplyToEndpointReference();
int mep = axisOperation.getAxisSpecificMEPConstant();
if(mep == WSDLConstants.MEP_CONSTANT_OUT_ONLY){
client.fireAndForget(msgCtx.getEnvelope().getBody().cloneOMElement().getFirstElement());
} else if (replyTo == null || replyTo.hasAnonymousAddress()){
//It is sync2way and therefore we should fail
transaction = storageManager.getTransaction();
RMSBeanMgr mgr = storageManager.getRMSBeanMgr();
RMSBean finder = new RMSBean();
finder.setSequenceID(oldRMSBean.getSequenceID());
RMSBean bean = mgr.findUnique(finder);
oldRMSBean.setReallocated(Sandesha2Constants.WSRM_COMMON.REALLOCATION_FAILED);
storageManager.getRMSBeanMgr().update(oldRMSBean);
throw new SandeshaException(SandeshaMessageKeys.reallocationForSyncRequestReplyNotSupported);
} else {