Package org.apache.sandesha2.wsrm

Examples of org.apache.sandesha2.wsrm.Sequence



      transaction = storageManager.getTransaction();
      
      if (rmMsg.getMessageType() == Sandesha2Constants.MessageTypes.APPLICATION) {
        Sequence sequence = (Sequence) rmMsg
            .getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);
       
        boolean highestMessage = false;
        if (sequence.getLastMessage() != null) {
          //this will work for RM 1.0 only
          highestMessage = true;
        } else {
          RMDBean rmdBean = SandeshaUtil.getRMDBeanFromSequenceId(storageManager, invokerBean.getSequenceID());
         
View Full Code Here


      if(env != null) {
        boolean lastMessageHeader = false;
        try {
          SOAPHeader header = env.getHeader();
          if(header != null) {
            Sequence sequence = new Sequence(Sandesha2Constants.SPEC_2005_02.NS_URI);
            sequence.fromOMElement(header);
            if(sequence.getLastMessage() != null) {
              lastMessageHeader = true;
            }
          }
        } catch(Exception e) {
          // Do nothing, we failed to find a Sequence header
View Full Code Here

 
  private static void processApplicationMessage(RMMsgContext rmMsgCtx) throws AxisFault {
    if (log.isDebugEnabled())
      log.debug("Enter: SandeshaGlobalInHandler::processApplicationMessage");
    // Check if this is a duplicate message
    Sequence sequence = (Sequence) rmMsgCtx.getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);
    String sequenceId = sequence.getIdentifier().getIdentifier();
    long msgNo = sequence.getMessageNumber().getMessageNumber();

    StorageManager storageManager =
      SandeshaUtil.getSandeshaStorageManager(rmMsgCtx.getConfigurationContext(),
          rmMsgCtx.getConfigurationContext().getAxisConfiguration());
   
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 = (Sequence) rmMsgCtx.getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);
    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 = (Sequence) rmMsgCtx.getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);
    String sequenceId = sequence.getIdentifier().getIdentifier();
    long msgNo = sequence.getMessageNumber().getMessageNumber();
    boolean lastMessage = sequence.getLastMessage() != null;
   
    // Check that both the Sequence header and message body have been secured properly
    RMDBeanMgr mgr = storageManager.getRMDBeanMgr();
    RMDBean bean = mgr.retrieve(sequenceId);
   
    if(bean != null && bean.getSecurityTokenData() != null) {
      SecurityManager secManager = SandeshaUtil.getSecurityManager(msgCtx.getConfigurationContext());
     
      QName seqName = new QName(rmMsgCtx.getRMNamespaceValue(), Sandesha2Constants.WSRM_COMMON.SEQUENCE);
     
      SOAPEnvelope envelope = msgCtx.getEnvelope();
      OMElement body = envelope.getBody();
      OMElement seqHeader = envelope.getHeader().getFirstChildWithName(seqName);
     
      SecurityToken token = secManager.recoverSecurityToken(bean.getSecurityTokenData());
     
      secManager.checkProofOfPossession(token, seqHeader, msgCtx);
      secManager.checkProofOfPossession(token, body, msgCtx);
    }
   
    // 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 = rmMsgCtx.getMessageContext().getConfigurationContext();
    if (configCtx == null) {
      String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.configContextNotSet);
      log.debug(message);
      throw new SandeshaException(message);
    }

    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)) {
     
      if (log.isDebugEnabled())
        log.debug("Exit: SequenceProcessor::processReliableMessage, Message rolled over " + msgNo);
     
      return InvocationResponse.ABORT;
    }

    // Pause the messages bean if not the right message to invoke.
   
    // 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();
    String key = SandeshaUtil.getUUID(); // key to store the message.
    // 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(rmMsgCtx.getMessageContext())
            ||
          SandeshaUtil.isDuplicateInOutMessage(rmMsgCtx.getMessageContext()))
        && (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 with RM 1.0
      if((replyTo==null || replyTo.hasAnonymousAddress()) &&
         (specVersion!=null && specVersion.equals(Sandesha2Constants.SPEC_VERSIONS.v1_0))) {

        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().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

  public static String getSequenceIDFromRMMessage(RMMsgContext rmMessageContext) throws SandeshaException {
    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) {
      Iterator sequenceAckIter = rmMessageContext
          .getMessageParts(Sandesha2Constants.MessageParts.SEQ_ACKNOWLEDGEMENT);
     
      //In case of ack messages sequenceId is decided based on the sequenceId of the first
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

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

    String sequenceID = null;
    if (messageType == Sandesha2Constants.MessageTypes.APPLICATION) {
      Sequence sequence = rmMessageContext.getSequence();
      sequenceID = sequence.getIdentifier().getIdentifier();
    } else if (messageType == Sandesha2Constants.MessageTypes.ACK) {
      Iterator<SequenceAcknowledgement> sequenceAckIter = rmMessageContext
          .getSequenceAcknowledgements();
     
      //In case of ack messages sequenceId is decided based on the sequenceId of the first
View Full Code Here

    int messageType = rmMsgCtx.getMessageType();
    if (messageType==Sandesha2Constants.MessageTypes.UNKNOWN) {
      MessageContext requestMsgCtx = msgCtx.getOperationContext().getMessageContext(OperationContextFactory.MESSAGE_LABEL_IN_VALUE);
      if (requestMsgCtx!=null) {  //for the server side
        RMMsgContext reqRMMsgCtx = MsgInitializer.initializeMessage(requestMsgCtx);
        Sequence sequencePart = (Sequence) reqRMMsgCtx.getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);
        if (sequencePart!=null)
          msgProcessor = new ApplicationMsgProcessor ();// a rm intended message.
      } else if (!msgCtx.isServerSide()) //if client side.
          msgProcessor = new ApplicationMsgProcessor ();
    }else  {
View Full Code Here

    boolean drop = false;

    if (rmMsgContext.getMessageType() == Sandesha2Constants.MessageTypes.APPLICATION) {

      Sequence sequence = (Sequence) rmMsgContext
          .getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);
      String sequenceId = null;

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

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

      if (sequenceId != null && msgNo > 0) {
        StorageManager storageManager = SandeshaUtil
            .getSandeshaStorageManager(rmMsgContext
                .getMessageContext().getConfigurationContext());
        SequencePropertyBeanMgr seqPropMgr = storageManager
            .getSequencePropretyBeanMgr();
        SequencePropertyBean receivedMsgsBean = seqPropMgr.retrieve(
            sequenceId,
            Sandesha2Constants.SequenceProperties.SERVER_COMPLETED_MESSAGES);
        if (receivedMsgsBean != null) {
          String receivedMsgStr = (String) receivedMsgsBean
              .getValue();
          ArrayList msgNoArrList = SandeshaUtil
              .getSplittedMsgNoArraylist(receivedMsgStr);

          Iterator iterator = msgNoArrList.iterator();
          while (iterator.hasNext()) {
            String temp = (String) iterator.next();
            String msgNoStr = new Long(msgNo).toString();
            if (msgNoStr.equals(temp)) {
              drop = true;
            }
          }
        }

        if (drop == false) {
          //Checking for RM specific EMPTY_BODY LASTMESSAGE.
          SOAPBody body = rmMsgContext.getSOAPEnvelope().getBody();
          boolean emptyBody = false;
          if (body.getChildElements().hasNext() == false) {
            emptyBody = true;
          }

          if (emptyBody) {
            if (sequence.getLastMessage() != null) {
              log.info ("Empty Body LastMessage Received");
              drop = true;

              if (receivedMsgsBean == null) {
                receivedMsgsBean = new SequencePropertyBean(
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.