Package org.apache.sandesha2.wsrm

Examples of org.apache.sandesha2.wsrm.Sequence


  }

  private void processDroppedMessage(RMMsgContext rmMsgContext)
      throws SandeshaException {
    if (rmMsgContext.getMessageType() == Sandesha2Constants.MessageTypes.APPLICATION) {
      Sequence sequence = (Sequence) rmMsgContext
          .getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);
      String sequenceId = null;

      if (sequence != null) {
        sequenceId = sequence.getIdentifier().getIdentifier();
      }

      StorageManager storageManager = SandeshaUtil
          .getSandeshaStorageManager(rmMsgContext.getMessageContext()
              .getConfigurationContext());
View Full Code Here


        Transaction preSendTransaction = storageManager.getTransaction();

        int messageType = rmMsgCtx.getMessageType();
        if (messageType == Sandesha2Constants.MessageTypes.APPLICATION) {
          Sequence sequence = (Sequence) rmMsgCtx.getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);
          String sequenceID = sequence.getIdentifier().getIdentifier();
 
        }
       
        //checking weather this message can carry piggybacked acks
        if (isAckPiggybackableMsgType(messageType) && !isAckAlreadyPiggybacked(rmMsgCtx)) {
View Full Code Here

            MessageContext msgToInvoke = storageManager.retrieveMessageContext(key,context);

            RMMsgContext rmMsg = MsgInitializer
                .initializeMessage(msgToInvoke);
            Sequence seq = (Sequence) rmMsg
                .getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);

            long msgNo = seq.getMessageNumber().getMessageNumber();

            try {
              //Invoking the message.

              //currently Transaction based invocation can be supplied only for the in-only case.
             
              if (!AxisOperationFactory.MEP_URI_IN_ONLY.equals(msgToInvoke.getAxisOperation().getMessageExchangePattern())) {
                invocationTransaction.commit();
              }
             
              new AxisEngine (msgToInvoke.getConfigurationContext())
                  .resume(msgToInvoke);
              invoked = true;
             
              if (!AxisOperationFactory.MEP_URI_IN_ONLY.equals(msgToInvoke.getAxisOperation().getMessageExchangePattern())) {
                invocationTransaction = storageManager.getTransaction();
              }           

              storageMapMgr.delete(key);
            } catch (AxisFault e) {
              throw new SandeshaException(e);
            }

            //undating the next msg to invoke


            if (rmMsg.getMessageType() == Sandesha2Constants.MessageTypes.APPLICATION) {
              Sequence sequence = (Sequence) rmMsg
                  .getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);
              if (sequence.getLastMessage() != null) {
               
                TerminateManager.cleanReceivingSideAfterInvocation(context, sequenceId);
               
                //this sequence has no more invocations
//                stopInvokerForTheSequence(sequenceId);
View Full Code Here

        MessageContext highestInMsg = storageManager.retrieveMessageContext(highestImMsgKey,configCtx);
        MessageContext highestOutMessage = highestInMsg.getOperationContext().getMessageContext(OperationContextFactory.MESSAGE_LABEL_OUT_VALUE);
       
        if (highestOutMessage!=null) {
          RMMsgContext highestOutRMMsg = MsgInitializer.initializeMessage(highestOutMessage);
          Sequence seqPartOfOutMsg = (Sequence) highestOutRMMsg.getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);
       
          if (seqPartOfOutMsg!=null) {
           
            //response message of the last in message can be considered as the last out message.
            highestOutMsgNo = seqPartOfOutMsg.getMessageNumber().getMessageNumber();
            SequencePropertyBean highestOutMsgBean = new SequencePropertyBean (
                responseSideInternalSequenceID,
                Sandesha2Constants.SequenceProperties.LAST_OUT_MESSAGE_NO,
                new Long(highestOutMsgNo).toString() );
         
View Full Code Here

   *
   * @param msgCtx
   * @return
   */
  public RMMsgContext checkForLastMsgNumberExceeded(RMMsgContext  applicationRMMessage) throws SandeshaException {
    Sequence sequence = (Sequence) applicationRMMessage.getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);
    long messageNumber = sequence.getMessageNumber().getMessageNumber();
    String sequenceID = sequence.getIdentifier().getIdentifier();
   
    ConfigurationContext configCtx = applicationRMMessage.getMessageContext().getConfigurationContext();
    StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(configCtx);
    SequencePropertyBeanMgr seqPropMgr = storageManager.getSequencePropretyBeanMgr();
   
View Full Code Here

    }
   
    SequencePropertyBeanMgr seqPropMgr = storageManager.getSequencePropretyBeanMgr();
   
    //setting acked msg no range
    Sequence sequence = (Sequence) rmMsgCtx
        .getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);
    String sequenceId = sequence.getIdentifier().getIdentifier();
    ConfigurationContext configCtx = rmMsgCtx.getMessageContext()
        .getConfigurationContext();
    if (configCtx == null) {
      String message = "Configuration Context is null";
      log.debug(message);
      throw new SandeshaException(message);
    }

    faultMessageContext = faultManager.checkForUnknownSequence(rmMsgCtx,sequenceId);
    if (faultMessageContext != null) {
      ConfigurationContext configurationContext = msgCtx.getConfigurationContext();
      AxisEngine engine = new AxisEngine(configurationContext);
     
      try {
        engine.send(faultMessageContext.getMessageContext());
      } catch (AxisFault e) {
        throw new SandeshaException ("Could not send the fault message",e);
      }
     
      return;
    }
   
    //setting mustUnderstand to false.
    sequence.setMustUnderstand(false);
    rmMsgCtx.addSOAPEnvelope();
   
    //throwing a fault if the sequence is closed.
    faultMessageContext = faultManager. checkForSequenceClosed(rmMsgCtx,sequenceId);
    if (faultMessageContext != null) {
      ConfigurationContext configurationContext = msgCtx.getConfigurationContext();
      AxisEngine engine = new AxisEngine(configurationContext);
     
      try {
        engine.sendFault(faultMessageContext.getMessageContext());
      } catch (AxisFault e) {
        throw new SandeshaException ("Could not send the fault message",e);
      }
     
      return;
    }

    Transaction lastUpdatedTimeTransaction = storageManager.getTransaction();
   
    //updating the last activated time of the sequence.
    SequenceManager.updateLastActivatedTime(sequenceId,configCtx);
    lastUpdatedTimeTransaction.commit();
   
    Transaction updataMsgStringTransaction = storageManager
        .getTransaction();
   
    SequencePropertyBean msgsBean = seqPropMgr.retrieve(sequenceId,
        Sandesha2Constants.SequenceProperties.SERVER_COMPLETED_MESSAGES);

    long msgNo = sequence.getMessageNumber().getMessageNumber();
    if (msgNo == 0) {
      String message = "Wrong message number";
      log.debug(message);
      throw new SandeshaException(message);
    }
View Full Code Here

    StorageManager storageManager = SandeshaUtil
        .getSandeshaStorageManager(msgCtx.getConfigurationContext());
    SequencePropertyBeanMgr seqPropMgr = storageManager
        .getSequencePropretyBeanMgr();

    Sequence sequence = (Sequence) rmMsgCtx
        .getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);
    String sequenceId = sequence.getIdentifier().getIdentifier();
    ConfigurationContext configCtx = rmMsgCtx.getMessageContext()
        .getConfigurationContext();
    if (configCtx == null)
      throw new SandeshaException("Configuration Context is null");
View Full Code Here

        throw new SandeshaException (e);
      }

      RMMsgContext requestRMMsgCtx = MsgInitializer.initializeMessage(reqMsgCtx);

      Sequence reqSequence = (Sequence) requestRMMsgCtx.getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);
      if (reqSequence == null) {
        String message = "Sequence part is null";
        log.debug(message);
        throw new SandeshaException(message);
      }

      String incomingSeqId = reqSequence.getIdentifier().getIdentifier();
      if (incomingSeqId == null || incomingSeqId == "") {
        String message = "Invalid seqence Id";
        log.debug(message);
        throw new SandeshaException(message);
      }

      long requestMsgNo = reqSequence.getMessageNumber().getMessageNumber();
     
      internalSequenceId = SandeshaUtil.getOutgoingSideInternalSequenceID(incomingSeqId);
     
      //deciding weather the last message.
      String requestLastMsgNoStr = SandeshaUtil.getSequenceProperty(incomingSeqId,Sandesha2Constants.SequenceProperties.LAST_IN_MESSAGE_NO,configContext);
      if (requestLastMsgNoStr!=null) {
        long requestLastMsgNo = Long.parseLong(requestLastMsgNoStr);
        if (requestLastMsgNo==requestMsgNo)
          lastMessage = true;
      }

    } else {
      // set the internal sequence id for the client side.
      EndpointReference toEPR = msgContext.getTo();
      if (toEPR == null || toEPR.getAddress() == null || "".equals(toEPR.getAddress())) {
        String message = "TO End Point Reference is not set correctly. This is a must for the sandesha client side.";
        log.debug(message);
        throw new SandeshaException(message);
      }

      String to = toEPR.getAddress();
      String sequenceKey = (String) msgContext.getProperty(SandeshaClientConstants.SEQUENCE_KEY);
      internalSequenceId = SandeshaUtil.getInternalSequenceID(to,sequenceKey);
     
      String lastAppMessage = (String) msgContext.getProperty(SandeshaClientConstants.LAST_MESSAGE);
      if (lastAppMessage!=null && "true".equals(lastAppMessage))
        lastMessage = true;
    }

    /* checking weather the user has given the messageNumber (most of the cases this will not be the case where
       the system will generate the message numbers */

    //User should set it as a long object.
    Long messageNumberLng = (Long) msgContext.getProperty(SandeshaClientConstants.MESSAGE_NUMBER);
   
    long givenMessageNumber = -1;
    if (messageNumberLng!=null) {
      givenMessageNumber = messageNumberLng.longValue();
      if (givenMessageNumber<=0) {
        throw new SandeshaException ("The givem message number value is invalid (has to be larger than zero)");
      }
    }
   
    //the message number that was last used.
    long systemMessageNumber = getPreviousMsgNo(configContext, internalSequenceId);
   
    //The number given by the user has to be larger than the last stored number.
    if (givenMessageNumber>0 && givenMessageNumber<=systemMessageNumber) {
      String message = "The given message number is not larger than value of the last sent message.";
      throw new SandeshaException (message);
    }
   
    //Finding the correct message number.
    long messageNumber = -1;
    if (givenMessageNumber>0)          // if given message number is valid use it. (this is larger than the last stored due to the last check)
      messageNumber = givenMessageNumber;
    else if (systemMessageNumber>0) {  //if system message number is valid use it.
      messageNumber = systemMessageNumber+1;
    } else {         //This is the fist message (systemMessageNumber = -1)
      messageNumber = 1;
    }
   
    //A dummy message is a one which will not be processed as a actual application message.
    //The RM handlers will simply let these go.
    String dummyMessageString = (String) msgContext.getOptions().getProperty(SandeshaClientConstants.DUMMY_MESSAGE);
    boolean dummyMessage = false;
    if (dummyMessageString!=null && Sandesha2Constants.VALUE_TRUE.equals(dummyMessageString))
      dummyMessage = true;
   
    //saving the used message number
    if (!dummyMessage)
      setNextMsgNo(configContext,internalSequenceId,messageNumber);
     
    //set this as the response highest message.
    SequencePropertyBean responseHighestMsgBean = new SequencePropertyBean (
        internalSequenceId,
        Sandesha2Constants.SequenceProperties.HIGHEST_OUT_MSG_NUMBER,
        new Long (messageNumber).toString()
    );
    seqPropMgr.insert(responseHighestMsgBean);
   
    if (lastMessage) {
 
      SequencePropertyBean responseHighestMsgKeyBean = new SequencePropertyBean (
          internalSequenceId,
          Sandesha2Constants.SequenceProperties.HIGHEST_OUT_MSG_KEY,
          storageKey
      )
     
      SequencePropertyBean responseLastMsgKeyBean = new SequencePropertyBean (
          internalSequenceId,
          Sandesha2Constants.SequenceProperties.LAST_OUT_MESSAGE_NO,
          new Long (messageNumber).toString()
      )
     
      seqPropMgr.insert(responseHighestMsgKeyBean);
      seqPropMgr.insert(responseLastMsgKeyBean);
    }
   
    boolean sendCreateSequence = false;

    SequencePropertyBean outSeqBean = seqPropMgr.retrieve(
        internalSequenceId,
        Sandesha2Constants.SequenceProperties.OUT_SEQUENCE_ID);

    // setting async ack endpoint for the server side. (if present)
    if (serverSide) {
      String incomingSequenceID = SandeshaUtil
          .getServerSideIncomingSeqIdFromInternalSeqId(internalSequenceId);
      SequencePropertyBean incomingToBean = seqPropMgr.retrieve(
          incomingSequenceID,
          Sandesha2Constants.SequenceProperties.TO_EPR);
      if (incomingToBean != null) {
        String incomingTo = incomingToBean.getValue();
        msgContext.setProperty(SandeshaClientConstants.AcksTo, incomingTo);
      }
    }

   
    //FINDING THE SPEC VERSION
    String specVersion = null;
    if (msgContext.isServerSide()) {
      //in the server side, get the RM version from the request sequence.
      MessageContext requestMessageContext;
      try {
        requestMessageContext = msgContext.getOperationContext().getMessageContext(AxisOperationFactory.MESSAGE_LABEL_IN_VALUE);
      } catch (AxisFault e) {
        throw new SandeshaException (e);
      }
     
      if (requestMessageContext==null)
        throw new SandeshaException ("Request message context is null, cant find out the request side sequenceID");
     
      RMMsgContext requestRMMsgCtx = MsgInitializer.initializeMessage(requestMessageContext);
      Sequence sequence = (Sequence) requestRMMsgCtx.getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);
     
      String requestSequenceID = sequence.getIdentifier().getIdentifier();
      SequencePropertyBean specVersionBean = seqPropMgr.retrieve(requestSequenceID,Sandesha2Constants.SequenceProperties.RM_SPEC_VERSION);
      if (specVersionBean==null)
        throw new SandeshaException ("SpecVersion sequence property bean is not available for the incoming sequence. Cant find the RM version for outgoing side");
     
      specVersion = specVersionBean.getValue();
View Full Code Here

    if (rmVersion==null)
      throw new SandeshaException ("Cant find the rmVersion of the given message");
   
    String rmNamespaceValue = SpecSpecificConstants.getRMNamespaceValue(rmVersion);
   
    Sequence sequence = new Sequence(factory,rmNamespaceValue);
    MessageNumber msgNumber = new MessageNumber(factory,rmNamespaceValue);
    msgNumber.setMessageNumber(messageNumber);
    sequence.setMessageNumber(msgNumber);

    boolean lastMessage = false;
    // setting last message
    if (msg.isServerSide()) {
      MessageContext requestMsg = null;

      try {
        requestMsg = msg.getOperationContext().getMessageContext(OperationContextFactory.MESSAGE_LABEL_IN_VALUE);
      } catch (AxisFault e) {
        throw new SandeshaException(e.getMessage());
      }

      RMMsgContext reqRMMsgCtx = MsgInitializer.initializeMessage(requestMsg);
      Sequence requestSequence = (Sequence) reqRMMsgCtx.getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);
      if (requestSequence == null) {
        String message = "Request Sequence is null";
        log.debug(message);
        throw new SandeshaException(message);
      }

      if (requestSequence.getLastMessage() != null) {
        lastMessage = true;
        sequence.setLastMessage(new LastMessage(factory,rmNamespaceValue));

      }
View Full Code Here

  public static String getSequenceIDFromRMMessage(RMMsgContext rmMessageContext) {
    int messageType = rmMessageContext.getMessageType();

    String sequenceID = null;
    if (messageType == Sandesha2Constants.MessageTypes.APPLICATION) {
      Sequence sequence = (Sequence) rmMessageContext.getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);
      sequenceID = sequence.getIdentifier().getIdentifier();
    } else if (messageType == Sandesha2Constants.MessageTypes.ACK) {
      SequenceAcknowledgement sequenceAcknowledgement = (SequenceAcknowledgement) rmMessageContext
          .getMessagePart(Sandesha2Constants.MessageParts.SEQ_ACKNOWLEDGEMENT);
      sequenceID = sequenceAcknowledgement.getIdentifier().getIdentifier();
    } else if (messageType == Sandesha2Constants.MessageTypes.ACK_REQUEST) {
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.