// response
// message.
} catch (AxisFault e1) {
throw new SandeshaException(e1);
}
SequencePropertyBeanMgr seqPropMgr = storageManager.getSequencePropertyBeanMgr();
try {
String newSequenceId = SequenceManager.setupNewSequence(createSeqRMMsg, storageManager); // newly
// created
// sequnceID.
RMMsgContext createSeqResponse = RMMsgCreator.createCreateSeqResponseMsg(createSeqRMMsg, outMessage,
newSequenceId, storageManager); // converting the blank out
// message in to a create
// sequence response.
createSeqResponse.setFlow(MessageContext.OUT_FLOW);
createSeqResponse.setProperty(Sandesha2Constants.APPLICATION_PROCESSING_DONE, "true"); // for
// making
// sure
// that
// this
// wont
// be
// processed
// again.
CreateSequenceResponse createSeqResPart = (CreateSequenceResponse) createSeqResponse
.getMessagePart(Sandesha2Constants.MessageParts.CREATE_SEQ_RESPONSE);
// OFFER PROCESSING
SequenceOffer offer = createSeqPart.getSequenceOffer();
if (offer != null) {
Accept accept = createSeqResPart.getAccept();
if (accept == null) {
String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.noAcceptPart);
log.debug(message);
throw new SandeshaException(message);
}
String offeredSequenceID = offer.getIdentifer().getIdentifier(); // offered
// seq.
// id.
boolean offerEcepted = offerAccepted(offeredSequenceID, context, createSeqRMMsg, storageManager);
if (offerEcepted) {
// Setting the CreateSequence table entry for the outgoing
// side.
RMSBean rmsBean = new RMSBean();
rmsBean.setSequenceID(offeredSequenceID);
String outgoingSideInternalSequenceId = SandeshaUtil
.getOutgoingSideInternalSequenceID(newSequenceId);
rmsBean.setInternalSequenceID(outgoingSideInternalSequenceId);
rmsBean.setCreateSeqMsgID(SandeshaUtil.getUUID()); // this
// is a
// dummy
// value.
String outgoingSideSequencePropertyKey = outgoingSideInternalSequenceId;
RMSBeanMgr rmsBeanMgr = storageManager.getRMSBeanMgr();
rmsBeanMgr.insert(rmsBean);
// Setting sequence properties for the outgoing sequence.
// Only will be used by the server side response path. Will
// be wasted properties for the client side.
// setting the out_sequence_id
SequencePropertyBean outSequenceBean = new SequencePropertyBean();
outSequenceBean.setName(Sandesha2Constants.SequenceProperties.OUT_SEQUENCE_ID);
outSequenceBean.setValue(offeredSequenceID);
outSequenceBean.setSequencePropertyKey(outgoingSideSequencePropertyKey);
seqPropMgr.insert(outSequenceBean);
// setting the internal_sequence_id
SequencePropertyBean internalSequenceBean = new SequencePropertyBean();
internalSequenceBean.setName(Sandesha2Constants.SequenceProperties.INTERNAL_SEQUENCE_ID);
internalSequenceBean.setSequencePropertyKey(offeredSequenceID);
internalSequenceBean.setValue(outgoingSideInternalSequenceId);
seqPropMgr.insert(internalSequenceBean);
Endpoint endpoint = offer.getEndpoint();
if (endpoint!=null) {
// setting the OfferedEndpoint
SequencePropertyBean offeredEndpointBean = new SequencePropertyBean();
offeredEndpointBean.setName(Sandesha2Constants.SequenceProperties.OFFERED_ENDPOINT);
//currently we can only serialize the Address part of the Endpoint.
//TODO correct this to serialize the whole EPR.
offeredEndpointBean.setValue(endpoint.getEPR().getAddress());
offeredEndpointBean.setSequencePropertyKey(outgoingSideSequencePropertyKey);
seqPropMgr.insert(offeredEndpointBean);
}
} else {
// removing the accept part.
createSeqResPart.setAccept(null);
createSeqResponse.addSOAPEnvelope();
}
}
EndpointReference acksTo = createSeqPart.getAcksTo().getEPR();
if (acksTo == null || acksTo.getAddress() == null || "".equals(acksTo.getAddress())) {
String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.noAcksToPartInCreateSequence);
log.debug(message);
throw new AxisFault(message);
}
//TODO add createSequenceResponse message as the referenceMessage to the NextMsgBean.
SequencePropertyBean acksToBean = new SequencePropertyBean(newSequenceId,
Sandesha2Constants.SequenceProperties.ACKS_TO_EPR, acksTo.getAddress());
seqPropMgr.insert(acksToBean);
outMessage.setResponseWritten(true);
// commiting tr. before sending the response msg.
SequenceManager.updateLastActivatedTime(newSequenceId, storageManager);
AxisEngine engine = new AxisEngine(context);
engine.send(outMessage);
SequencePropertyBean toBean = seqPropMgr.retrieve(newSequenceId,
Sandesha2Constants.SequenceProperties.TO_EPR);
if (toBean == null) {
String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.toEPRNotValid, null);
log.debug(message);
throw new SandeshaException(message);