Package org.apache.sandesha2.wsrm

Examples of org.apache.sandesha2.wsrm.SequenceAcknowledgement


      SOAPEnvelope newEnvelope = factory.getDefaultEnvelope();
      applicationMsg.setSOAPEnvelop(newEnvelope);
    }
    envelope = applicationMsg.getSOAPEnvelope();

    SequenceAcknowledgement sequenceAck = new SequenceAcknowledgement(
        factory);
    Identifier id = new Identifier(factory);
    id.setIndentifer(sequenceId);
    sequenceAck.setIdentifier(id);

    ConfigurationContext ctx = applicationMsg.getMessageContext()
        .getConfigurationContext();
    StorageManager storageManager = SandeshaUtil
        .getSandeshaStorageManager(ctx);
    SequencePropertyBeanMgr seqPropMgr = storageManager
        .getSequencePropretyBeanMgr();

    SequencePropertyBean seqBean = seqPropMgr.retrieve(sequenceId,
        Sandesha2Constants.SequenceProperties.RECEIVED_MESSAGES);
    String msgNoList = (String) seqBean.getValue();

    ArrayList ackRangeArrayList = SandeshaUtil.getAckRangeArrayList(msgNoList,factory);
    Iterator iterator = ackRangeArrayList.iterator();
    while (iterator.hasNext()) {
      AcknowledgementRange ackRange = (AcknowledgementRange) iterator.next();
      sequenceAck.addAcknowledgementRanges(ackRange);
    }

    sequenceAck.toOMElement(envelope.getHeader());
    applicationMsg
        .setAction(Sandesha2Constants.WSRM.Actions.ACTION_SEQUENCE_ACKNOWLEDGEMENT);
    applicationMsg
        .setSOAPAction(Sandesha2Constants.WSRM.Actions.SOAP_ACTION_SEQUENCE_ACKNOWLEDGEMENT);
    applicationMsg.setMessageId(SandeshaUtil.getUUID());
View Full Code Here


      RMMsgContext ackRMMsgContext = MsgInitializer
          .initializeMessage(ackMsgContext);
      if (ackRMMsgContext.getMessageType() != Sandesha2Constants.MessageTypes.ACK)
        throw new SandeshaException("Invalid ack message entry");

      SequenceAcknowledgement sequenceAcknowledgement = (SequenceAcknowledgement) ackRMMsgContext
          .getMessagePart(Sandesha2Constants.MessageParts.SEQ_ACKNOWLEDGEMENT);
      applicationRMMsgContext.setMessagePart(
          Sandesha2Constants.MessageParts.SEQ_ACKNOWLEDGEMENT,
          sequenceAcknowledgement);
View Full Code Here

  public void processMessage(RMMsgContext terminateSeqRMMSg)
      throws SandeshaException {

    MessageContext terminateSeqMsg = terminateSeqRMMSg.getMessageContext();
    //Processing for ack if any
    SequenceAcknowledgement sequenceAck = (SequenceAcknowledgement) terminateSeqRMMSg
        .getMessagePart(Sandesha2Constants.MessageParts.SEQ_ACKNOWLEDGEMENT);
    if (sequenceAck != null) {
      AcknowledgementProcessor ackProcessor = new AcknowledgementProcessor();
      ackProcessor.processMessage(terminateSeqRMMSg);
    }
View Full Code Here

  private boolean letInvoke = false;

  public void processMessage(RMMsgContext rmMsgCtx) throws SandeshaException {

    //Processing for ack if any
    SequenceAcknowledgement sequenceAck = (SequenceAcknowledgement) rmMsgCtx
        .getMessagePart(Sandesha2Constants.MessageParts.SEQ_ACKNOWLEDGEMENT);
    if (sequenceAck != null) {
      AcknowledgementProcessor ackProcessor = new AcknowledgementProcessor();
      ackProcessor.processMessage(rmMsgCtx);
    }
View Full Code Here

public class AcknowledgementProcessor implements MsgProcessor {

  public void processMessage(RMMsgContext rmMsgCtx) throws SandeshaException {

    SequenceAcknowledgement sequenceAck = (SequenceAcknowledgement) rmMsgCtx
        .getMessagePart(Sandesha2Constants.MessageParts.SEQ_ACKNOWLEDGEMENT);
    if (sequenceAck == null)
      throw new SandeshaException("Sequence acknowledgement part is null");

    AbstractContext context = rmMsgCtx.getContext();
    if (context == null)
      throw new SandeshaException("Context is null");

    StorageManager storageManager = SandeshaUtil
        .getSandeshaStorageManager(rmMsgCtx.getMessageContext()
            .getConfigurationContext());
    SenderBeanMgr retransmitterMgr = storageManager
        .getRetransmitterBeanMgr();
    SequencePropertyBeanMgr seqPropMgr = storageManager
        .getSequencePropretyBeanMgr();

    Iterator ackRangeIterator = sequenceAck.getAcknowledgementRanges()
        .iterator();

    Iterator nackIterator = sequenceAck.getNackList().iterator();
    String outSequenceId = sequenceAck.getIdentifier().getIdentifier();
    if (outSequenceId == null || "".equals(outSequenceId))
      throw new SandeshaException("OutSequenceId is null");

    SequencePropertyBean internalSequenceBean = seqPropMgr.retrieve(
        outSequenceId, Sandesha2Constants.SequenceProperties.INTERNAL_SEQUENCE_ID);

    if (internalSequenceBean == null || internalSequenceBean.getValue() == null)
      throw new SandeshaException("TempSequenceId is not set correctly");

    String internalSequenceId = (String) internalSequenceBean.getValue();

    //Following happens in the SandeshaGlobal handler
    rmMsgCtx.getMessageContext()
        .setProperty(Sandesha2Constants.ACK_PROCSSED, "true");

    //Removing relatesTo - Some WSRM endpoints tend to set relatesTo value
    // for ack messages.
    //Because of this dispatching may go wrong.
    //So we set relatesTo value to null for ackMessages. (this happens in
    // the SandeshaGlobal handler)
    //Do this only if this is a standalone ACK.
    if (rmMsgCtx.getMessageType() == Sandesha2Constants.MessageTypes.ACK)
      rmMsgCtx.setRelatesTo(null);

    SenderBean input = new SenderBean();
    input.setInternalSequenceId(internalSequenceId);
    Collection retransmitterEntriesOfSequence = retransmitterMgr
        .find(input);

    while (ackRangeIterator.hasNext()) {
      AcknowledgementRange ackRange = (AcknowledgementRange) ackRangeIterator
          .next();
      long lower = ackRange.getLowerValue();
      long upper = ackRange.getUpperValue();

      for (long messageNo = lower; messageNo <= upper; messageNo++) {
        SenderBean retransmitterBean = getRetransmitterEntry(
            retransmitterEntriesOfSequence, messageNo);
        if (retransmitterBean != null)
          retransmitterMgr.delete(retransmitterBean.getMessageId());
      }
    }

    while (nackIterator.hasNext()) {
      Nack nack = (Nack) nackIterator.next();
      long msgNo = nack.getNackNumber();

      //TODO - Process Nack
    }

    //following get called in the SandesaInHandler
    //if (justSendTerminateIfNeeded) {
    //If all messages up to last message have been acknowledged.
    //Add terminate Sequence message.
    SequencePropertyBean lastOutMsgBean = seqPropMgr.retrieve(
        internalSequenceId, Sandesha2Constants.SequenceProperties.LAST_OUT_MESSAGE);
    if (lastOutMsgBean != null) {
      Long lastOutMsgNoLng = (Long) lastOutMsgBean.getValue();
      if (lastOutMsgNoLng == null)
        throw new SandeshaException(
            "Invalid object set for the Last Out Message");

      long lastOutMessageNo = lastOutMsgNoLng.longValue();
      if (lastOutMessageNo <= 0)
        throw new SandeshaException(
            "Invalid value set for the last out message");

      boolean complete = SandeshaUtil.verifySequenceCompletion(
          sequenceAck.getAcknowledgementRanges().iterator(),
          lastOutMessageNo);

      if (complete) {
        addTerminateSequenceMessage(rmMsgCtx, outSequenceId,
            internalSequenceId);
View Full Code Here

    SOAPFactory factory = SOAPAbstractFactory.getSOAPFactory(SandeshaUtil
        .getSOAPVersion(createSeqResponseRMMsgCtx.getSOAPEnvelope()));

    //Processing for ack if any
    SequenceAcknowledgement sequenceAck = (SequenceAcknowledgement) createSeqResponseRMMsgCtx
        .getMessagePart(Sandesha2Constants.MessageParts.SEQ_ACKNOWLEDGEMENT);
    if (sequenceAck != null) {
      AcknowledgementProcessor ackProcessor = new AcknowledgementProcessor();
      ackProcessor.processMessage(createSeqResponseRMMsgCtx);
    }
View Full Code Here

            "Sequence part not found in the application message");

      sequenceId = sequence.getIdentifier().getIdentifier();

    } else if (rmMsgCtx.getMessageType() == Sandesha2Constants.MessageTypes.ACK) {
      SequenceAcknowledgement sequenceAcknowledgement = (SequenceAcknowledgement) rmMsgCtx
          .getMessagePart(Sandesha2Constants.MessageParts.SEQ_ACKNOWLEDGEMENT);
      sequenceId = sequenceAcknowledgement.getIdentifier()
          .getIdentifier();
    } else if (rmMsgCtx.getMessageType() == Sandesha2Constants.MessageTypes.TERMINATE_SEQ) {
      TerminateSequence terminateSequence = (TerminateSequence) rmMsgCtx
          .getMessagePart(Sandesha2Constants.MessageParts.TERMINATE_SEQ);
      sequenceId = terminateSequence.getIdentifier().getIdentifier();
View Full Code Here

    //TODO acked for not-send message
    RMMsgContext rmMsgContext = new RMMsgContext();
    if (rmMsgContext.getMessageType() != Sandesha2Constants.MessageTypes.ACK)
      return null;

    SequenceAcknowledgement sequenceAcknowledgement = (SequenceAcknowledgement) rmMsgContext
        .getMessagePart(Sandesha2Constants.MessageParts.SEQ_ACKNOWLEDGEMENT);
    List sequenceAckList = sequenceAcknowledgement
        .getAcknowledgementRanges();
    Iterator it = sequenceAckList.iterator();

    while (it.hasNext()) {
      AcknowledgementRange acknowledgementRange = (AcknowledgementRange) it
          .next();
      long upper = acknowledgementRange.getUpperValue();
      long lower = acknowledgementRange.getLowerValue();

      if (lower > upper) {
        //Invalid ack
        FaultData data = new FaultData();
        int SOAPVersion = SandeshaUtil.getSOAPVersion(msgCtx
            .getEnvelope());
        if (SOAPVersion == Sandesha2Constants.SOAPVersion.v1_1)
          data.setCode(SOAP11Constants.FAULT_CODE_SENDER);
        else
          data.setCode(SOAP12Constants.FAULT_CODE_SENDER);

        data.setSubcode(Sandesha2Constants.SOAPFaults.Subcodes.INVALID_ACKNOWLEDGEMENT);
        data.setSubcode("The SequenceAcknowledgement is invalid. Lower value is larger than upper value");
        data.setDetail(sequenceAcknowledgement.getOMElement());

        return getFault(rmMsgContext, data);
      }
    }
View Full Code Here

        sequenceId,  storageManager);
   
    Iterator iter = ackRMMessage.getMessageParts(Sandesha2Constants.MessageParts.SEQ_ACKNOWLEDGEMENT);
   
    if (iter.hasNext()) {
      SequenceAcknowledgement seqAck = (SequenceAcknowledgement) iter.next();
      if (seqAck==null) {
        String message = "No SequenceAcknowledgement part is present";
        throw new SandeshaException (message);
      }
   
View Full Code Here

   
    Iterator sequenceAckIter = ackRMMessageContext.getMessageParts(
        Sandesha2Constants.MessageParts.SEQ_ACKNOWLEDGEMENT);
   
    while (sequenceAckIter.hasNext()) {
      SequenceAcknowledgement sequenceAcknowledgement = (SequenceAcknowledgement) sequenceAckIter.next();
      List sequenceAckList = sequenceAcknowledgement.getAcknowledgementRanges();
      Iterator it = sequenceAckList.iterator();

      while (it.hasNext()) {
        AcknowledgementRange acknowledgementRange = (AcknowledgementRange) it.next();
        long upper = acknowledgementRange.getUpperValue();
        long lower = acknowledgementRange.getLowerValue();

        if (lower > upper) {
          invalidAck = true;
          reason = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.ackInvalid, Long.toString(lower), Long
              .toString(upper));
        }
      }

      if (invalidAck) {
        FaultData data = new FaultData();
        int SOAPVersion = SandeshaUtil.getSOAPVersion(ackMessageContext.getEnvelope());
        if (SOAPVersion == Sandesha2Constants.SOAPVersion.v1_1)
          data.setCode(SOAP11Constants.FAULT_CODE_SENDER);
        else
          data.setCode(SOAP12Constants.FAULT_CODE_SENDER);

        data.setSubcode(Sandesha2Constants.SOAPFaults.Subcodes.INVALID_ACKNOWLEDGEMENT);
        data.setReason(reason);

        SOAPFactory factory = SOAPAbstractFactory.getSOAPFactory(SOAPVersion);
        OMElement dummyElement = factory.createOMElement("dummyElem", null);
        sequenceAcknowledgement.toOMElement(dummyElement);

        OMElement sequenceAckElement = dummyElement.getFirstChildWithName(new QName(
            Sandesha2Constants.WSRM_COMMON.SEQUENCE_ACK));
        data.setDetail(sequenceAckElement);
View Full Code Here

TOP

Related Classes of org.apache.sandesha2.wsrm.SequenceAcknowledgement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.