Package org.apache.sandesha2.wsrm

Examples of org.apache.sandesha2.wsrm.Sequence


    CreateSequence createSequence = (CreateSequence) rmMsgCtx.getMessagePart(Sandesha2Constants.MessageParts.CREATE_SEQ);
    CreateSequenceResponse createSequenceResponse = (CreateSequenceResponse) rmMsgCtx.getMessagePart(Sandesha2Constants.MessageParts.CREATE_SEQ_RESPONSE);
    TerminateSequence terminateSequence = (TerminateSequence) rmMsgCtx.getMessagePart(Sandesha2Constants.MessageParts.TERMINATE_SEQ);
    TerminateSequenceResponse terminateSequenceResponse = (TerminateSequenceResponse) rmMsgCtx.getMessagePart(Sandesha2Constants.MessageParts.TERMINATE_SEQ_RESPONSE);
    SequenceAcknowledgement sequenceAcknowledgement = (SequenceAcknowledgement) rmMsgCtx.getMessagePart(Sandesha2Constants.MessageParts.SEQ_ACKNOWLEDGEMENT);
    Sequence sequence = (Sequence) rmMsgCtx.getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);
    AckRequested ackRequest = (AckRequested) rmMsgCtx.getMessagePart(Sandesha2Constants.MessageParts.ACK_REQUEST);
    CloseSequence closeSequence = (CloseSequence) rmMsgCtx.getMessagePart(Sandesha2Constants.MessageParts.CLOSE_SEQUENCE);
    CloseSequenceResponse closeSequenceResponse = (CloseSequenceResponse) rmMsgCtx.getMessagePart(Sandesha2Constants.MessageParts.CLOSE_SEQUENCE_RESPONSE);
   
    //Setting message type.
    if (createSequence != null) {
      rmMsgCtx.setMessageType(Sandesha2Constants.MessageTypes.CREATE_SEQ);
    }else if (createSequenceResponse != null) {
      rmMsgCtx.setMessageType(Sandesha2Constants.MessageTypes.CREATE_SEQ_RESPONSE);
      sequenceID = createSequenceResponse.getIdentifier().getIdentifier();
    }else if (terminateSequence != null) {
      rmMsgCtx.setMessageType(Sandesha2Constants.MessageTypes.TERMINATE_SEQ);
      sequenceID = terminateSequence.getIdentifier().getIdentifier();
    }else if (terminateSequenceResponse != null) {
      rmMsgCtx.setMessageType(Sandesha2Constants.MessageTypes.TERMINATE_SEQ_RESPONSE);
      sequenceID = terminateSequenceResponse.getIdentifier().getIdentifier();
    }else if (rmMsgCtx.getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE) != null) {
      rmMsgCtx.setMessageType(Sandesha2Constants.MessageTypes.APPLICATION);
      sequenceID = sequence.getIdentifier().getIdentifier();
    } else if (sequenceAcknowledgement != null) {
      rmMsgCtx.setMessageType(Sandesha2Constants.MessageTypes.ACK);
      sequenceID = sequenceAcknowledgement.getIdentifier().getIdentifier();
    } else if (ackRequest != null) {
      rmMsgCtx.setMessageType(Sandesha2Constants.MessageTypes.ACK_REQUEST);
View Full Code Here


      String assumedRMNamespace = SpecSpecificConstants.getRMNamespaceValue(rmVersion);
     
      RMMsgContext applicaionRMMsg = MsgInitializer
          .initializeMessage(applicationMsg);

      Sequence sequencePart = (Sequence) applicaionRMMsg
          .getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);
      if (sequencePart == null) {
        String message = "Sequence part is null";
        log.debug(message);
        throw new SandeshaException(message);
      }
     
      Identifier identifier = new Identifier(factory,assumedRMNamespace);
      identifier.setIndentifer(newOutSequenceId);

      sequencePart.setIdentifier(identifier);

      AckRequested ackRequestedPart = (AckRequested) applicaionRMMsg
          .getMessagePart(Sandesha2Constants.MessageParts.ACK_REQUEST);
      if (ackRequestedPart != null) {
        Identifier id1 = new Identifier(factory,assumedRMNamespace);
View Full Code Here

   
    // Generate the Sequence field.
    // -------------------------------
    String rmNamespaceValue = SpecSpecificConstants.getRMNamespaceValue(Sandesha2Constants.SPEC_VERSIONS.v1_1);

    Sequence sequence = new Sequence(rmNamespaceValue);
    sequence.setMessageNumber(1);
    Identifier id1 = new Identifier(rmNamespaceValue);
    id1.setIndentifer(uuid);
    sequence.setIdentifier(id1);
    applicationRMMsg.setSequence(sequence);
    applicationRMMsg.addSOAPEnvelope();

    // --------------------------------------------
    // Finished generating Sequence part
View Full Code Here

   
    // Generate the Sequence field.
    // -------------------------------
    String rmNamespaceValue = SpecSpecificConstants.getRMNamespaceValue(Sandesha2Constants.SPEC_VERSIONS.v1_1);

    Sequence sequence = new Sequence(rmNamespaceValue);
    sequence.setMessageNumber(Long.MAX_VALUE);
    Identifier id1 = new Identifier(rmNamespaceValue);
    id1.setIndentifer(uuid);
    sequence.setIdentifier(id1);
    applicationRMMsg.setSequence(sequence);
    applicationRMMsg.addSOAPEnvelope();

    // --------------------------------------------
    // Finished generating Sequence part
View Full Code Here

   
    // Generate the Sequence field.
    // -------------------------------
    String rmNamespaceValue = SpecSpecificConstants.getRMNamespaceValue(Sandesha2Constants.SPEC_VERSIONS.v1_1);

    Sequence sequence = new Sequence(rmNamespaceValue);
    sequence.setMessageNumber(1);
    Identifier id1 = new Identifier(rmNamespaceValue);
    id1.setIndentifer(uuid);
    sequence.setIdentifier(id1);
    applicationRMMsg.setSequence(sequence);
    applicationRMMsg.addSOAPEnvelope();

    // --------------------------------------------
    // Finished generating Sequence part
View Full Code Here

        storageManager.getRMDBeanMgr().update(rMDBean);
      }
     
      // Check if this is the last message
      if (rmMsg.getMessageType() == Sandesha2Constants.MessageTypes.APPLICATION) {
        Sequence sequence = rmMsg.getSequence();
       
        if (sequence.getLastMessage()) {
          //this will work for RM 1.0 only
          highestMessage = true;
        } else {
          if (rMDBean!=null && rMDBean.isTerminated()) {
            long highestInMsgNo = rMDBean.getHighestInMessageNumber();
View Full Code Here

  public InvocationResponse processSequenceHeader(RMMsgContext rmMsgCtx, Transaction transaction) throws AxisFault {
    if (log.isDebugEnabled())
      log.debug("Enter: SequenceProcessor::processSequenceHeader");
   
    InvocationResponse result = InvocationResponse.CONTINUE;
    Sequence sequence = rmMsgCtx.getSequence();
    if(sequence != null) {
      // This is a reliable message, so hand it on to the main routine
      result = processReliableMessage(rmMsgCtx, transaction);
    } else {
      if (log.isDebugEnabled())
View Full Code Here

      return result;
    }

    MessageContext msgCtx = rmMsgCtx.getMessageContext();
    StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(msgCtx.getConfigurationContext(),msgCtx.getConfigurationContext().getAxisConfiguration());
    Sequence sequence = rmMsgCtx.getSequence();
    String sequenceId = sequence.getIdentifier().getIdentifier();
    long msgNo = sequence.getMessageNumber();
    boolean lastMessage = sequence.getLastMessage();
   
    // Check that both the Sequence header and message body have been secured properly
    RMDBeanMgr mgr = storageManager.getRMDBeanMgr();
    RMDBean bean = mgr.retrieve(sequenceId);
   
    //check the security credentials
    SandeshaUtil.assertProofOfPossession(bean, msgCtx, msgCtx.getEnvelope().getHeader().
        getFirstChildWithName(new QName(rmMsgCtx.getRMNamespaceValue(), Sandesha2Constants.WSRM_COMMON.SEQUENCE)));
    SandeshaUtil.assertProofOfPossession(bean, msgCtx, msgCtx.getEnvelope().getBody());
   
   
    // Store the inbound sequence id, number and lastMessage onto the operation context
    OperationContext opCtx = msgCtx.getOperationContext();
    if(opCtx != null) {
      opCtx.setProperty(Sandesha2Constants.MessageContextProperties.INBOUND_SEQUENCE_ID, sequenceId);
      opCtx.setProperty(Sandesha2Constants.MessageContextProperties.INBOUND_MESSAGE_NUMBER, new Long(msgNo));
      if(lastMessage) opCtx.setProperty(Sandesha2Constants.MessageContextProperties.INBOUND_LAST_MESSAGE, Boolean.TRUE);
    }
   
    // setting acked msg no range
    ConfigurationContext configCtx = msgCtx.getConfigurationContext();
    if (configCtx == null) {
      String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.configContextNotSet);
      log.debug(message);
      throw new SandeshaException(message);
    }

    if(bean == null){
      if (FaultManager.checkForUnknownSequence(rmMsgCtx, sequenceId, storageManager, false)) {
        if (log.isDebugEnabled())
          log.debug("Exit: SequenceProcessor::processReliableMessage, Unknown sequence");
        return InvocationResponse.ABORT;
      }
    }

    // throwing a fault if the sequence is terminated
    if (FaultManager.checkForSequenceTerminated(rmMsgCtx, sequenceId, bean, false)) {
      if (log.isDebugEnabled())
        log.debug("Exit: SequenceProcessor::processReliableMessage, Sequence terminated");
      return InvocationResponse.ABORT;
    }
   
    // throwing a fault if the sequence is closed.
    if (FaultManager.checkForSequenceClosed(rmMsgCtx, sequenceId, bean, false)) {
      if (log.isDebugEnabled())
        log.debug("Exit: SequenceProcessor::processReliableMessage, Sequence closed");
      return InvocationResponse.ABORT;
    }
    FaultManager.checkForLastMsgNumberExceeded(rmMsgCtx, storageManager);
   
    if (FaultManager.checkForMessageRolledOver(rmMsgCtx, sequenceId, msgNo, bean)) {
     
      if (log.isDebugEnabled())
        log.debug("Exit: SequenceProcessor::processReliableMessage, Message rolled over " + msgNo);
     
      return InvocationResponse.ABORT;
    }

    // updating the last activated time of the sequence.
    bean.setLastActivatedTime(System.currentTimeMillis());
   
    if (lastMessage) {
      //setting this as the LastMessage number
      bean.setLastInMessageId(msgCtx.getMessageID());
    }
   
    EndpointReference replyTo = rmMsgCtx.getReplyTo();
    if (log.isDebugEnabled())
      log.debug("SequenceProcessor::processReliableMessage replyTo = " + replyTo);

    // Updating the server completed message ranges list
    RangeString serverCompletedMessageRanges = bean.getServerCompletedMessages();
    // See if the message is in the list of completed ranges
    boolean msgNoPresentInList =  serverCompletedMessageRanges.isMessageNumberInRanges(msgNo);
    if (!msgNoPresentInList){
       serverCompletedMessageRanges.addRange(new Range(msgNo));
    }

    // updating the Highest_In_Msg_No property which gives the highest
    // message number retrieved from this sequence.
    long highestInMsgNo = bean.getHighestInMessageNumber();

    if (msgNo > highestInMsgNo) {
      // If WS-Addressing is turned off there may not be a message id written into the SOAP
      // headers, but we can still fake one up to help us match up requests and replies within
      // this end of the connection.
      String messageId = msgCtx.getMessageID();
      if(messageId == null) {
        messageId = SandeshaUtil.getUUID();
        msgCtx.setMessageID(messageId);
      }
     
      bean.setHighestInMessageId(messageId);
      bean.setHighestInMessageNumber(msgNo);
    }
   
    String specVersion = rmMsgCtx.getRMSpecVersion();
    if ((SandeshaUtil.isDuplicateInOnlyMessage(msgCtx)
            ||
          SandeshaUtil.isDuplicateInOutMessage(msgCtx))
        && (Sandesha2Constants.QOS.InvocationType.DEFAULT_INVOCATION_TYPE == Sandesha2Constants.QOS.InvocationType.EXACTLY_ONCE)) {
     
      // this is a duplicate message and the invocation type is EXACTLY_ONCE. We try to return
      // ack messages at this point, as if someone is sending duplicates then they may have
      // 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
View Full Code Here

    if(messageType == Sandesha2Constants.MessageTypes.APPLICATION ||
       messageType == Sandesha2Constants.MessageTypes.LAST_MESSAGE) {
     
      String namespace = SpecSpecificConstants.getRMNamespaceValue(rmVersion);
      Sequence sequence = rmMsgContext.getSequence();
      if(sequence == null) {
        sequence = new Sequence(namespace);
        sequence.setMessageNumber(senderBean.getMessageNumber());

        if(senderBean.isLastMessage() &&
            SpecSpecificConstants.isLastMessageIndicatorRequired(rmVersion)) {
          sequence.setLastMessage(true);
        }
       
        // We just create the id here, we will add the value in later
        id = new Identifier(namespace);
        sequence.setIdentifier(id);
        rmMsgContext.setSequence(sequence);
       
      }
     
    } else if(messageType == Sandesha2Constants.MessageTypes.TERMINATE_SEQ) {
View Full Code Here

    CreateSequence createSequence = rmMsgContext.getCreateSequence();
    CreateSequenceResponse createSequenceResponse = rmMsgContext.getCreateSequenceResponse();
    TerminateSequence terminateSequence = rmMsgContext.getTerminateSequence();
    TerminateSequenceResponse terminateSequenceResponse = rmMsgContext.getTerminateSequenceResponse();
    Iterator<SequenceAcknowledgement> sequenceAcknowledgementsIter = rmMsgContext.getSequenceAcknowledgements();
    Sequence sequence = rmMsgContext.getSequence();
    Iterator<AckRequested> ackRequestedIter = rmMsgContext.getAckRequests();
    CloseSequence closeSequence = rmMsgContext.getCloseSequence();
    CloseSequenceResponse closeSequenceResponse = rmMsgContext.getCloseSequenceResponse();
    MakeConnection makeConnection = rmMsgContext.getMakeConnection();
   
    String rmNamespace = null;

    if (createSequence != null) {
      rmNamespace = createSequence.getNamespaceValue();
    }

    if (createSequenceResponse != null) {
      rmNamespace = createSequenceResponse.getNamespaceValue();
    }

    if (sequence != null) {
      rmNamespace = sequence.getNamespaceValue();
    }

    //In case of ack messages RM Namespace is decided based on the sequenceId of the last
    //sequence Ack. In other words Sandesha2 does not expect to receive two SequenceAcknowledgements
    //of different RM specifications in the same incoming message
    while(sequenceAcknowledgementsIter.hasNext()){
      SequenceAcknowledgement sequenceAck = (SequenceAcknowledgement) sequenceAcknowledgementsIter.next();
      rmNamespace = sequenceAck.getNamespaceValue();
    }

    if (terminateSequence != null) {
      rmNamespace = terminateSequence.getNamespaceValue();
    }

    if (terminateSequenceResponse != null) {
      rmNamespace = terminateSequenceResponse.getNamespaceValue();
    }

    //In case of ack request messages RM Namespace is decided based on the sequenceId of the last
    //ack request.
    while(ackRequestedIter.hasNext()){
      AckRequested ackRequest = (AckRequested) ackRequestedIter.next();
      rmNamespace = ackRequest.getNamespaceValue();
    }

    if (closeSequence != null) {
      rmNamespace = closeSequence.getNamespaceValue();
    }

    if (closeSequenceResponse != null) {
      rmNamespace = closeSequenceResponse.getNamespaceValue();
    }
   
    if (makeConnection != null) {
      if (Sandesha2Constants.SPEC_2007_02.MC_NS_URI.equals(makeConnection.getNamespaceValue()))
        rmNamespace = Sandesha2Constants.SPEC_2007_02.NS_URI;
    }
   
    if (rmMsgContext.getMessagePending() != null) {
      //MessagePending only supported in 1.1 namespace... no need to check the namespace value
      rmNamespace = Sandesha2Constants.SPEC_2007_02.NS_URI;
    }
    if (rmNamespace!=null)
      rmMsgContext.setRMNamespaceValue(rmNamespace);
     
    sequenceAcknowledgementsIter = rmMsgContext.getSequenceAcknowledgements();
    ackRequestedIter = rmMsgContext.getAckRequests();
   
    // Setting message type.
    if (createSequence != null) {
      rmMsgContext.setMessageType(Sandesha2Constants.MessageTypes.CREATE_SEQ);
    } else if (createSequenceResponse != null) {
      rmMsgContext.setMessageType(Sandesha2Constants.MessageTypes.CREATE_SEQ_RESPONSE);
      sequenceID = createSequenceResponse.getIdentifier().getIdentifier();
    } else if (terminateSequence != null) {
      rmMsgContext.setMessageType(Sandesha2Constants.MessageTypes.TERMINATE_SEQ);
      sequenceID = terminateSequence.getIdentifier().getIdentifier();
    } else if (terminateSequenceResponse != null) {
      rmMsgContext.setMessageType(Sandesha2Constants.MessageTypes.TERMINATE_SEQ_RESPONSE);
      sequenceID = terminateSequenceResponse.getIdentifier().getIdentifier();
    } else if (sequence != null) {
     
      Sequence seq = rmMsgContext.getSequence();
      boolean lastMessage = seq.getLastMessage();
      SOAPEnvelope envelope = rmMsgContext.getSOAPEnvelope();
     
      if (lastMessage && envelope.getBody().getFirstOMChild()==null) {
        //the message is an empty body last message
        rmMsgContext.setMessageType(Sandesha2Constants.MessageTypes.LAST_MESSAGE);
View Full Code Here

TOP

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

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.