Examples of RMSequenceBean


Examples of org.apache.sandesha2.storage.beans.RMSequenceBean

        if (size > 0) {
          //select one at random: TODO better method?
          Random random = new Random();
          possibleBeanIndex = random.nextInt(size);
          RMSequenceBean selectedSequence = (RMSequenceBean) possibleBeans.get(possibleBeanIndex);
          findSenderBean.setSequenceID(selectedSequence.getSequenceID());
          if (LoggingControl.isAnyTracingEnabled() && log.isDebugEnabled())
            log.debug("sequence selected " + findSenderBean.getSequenceID());
        } else {
          //we cannot match a RMD with the correct security credentials so we cannot process this msg under RSP
          if (LoggingControl.isAnyTracingEnabled() && log.isDebugEnabled())
            log.debug("Exit: MakeConnectionProcessor::processInMessage : no RM sequence bean with security credentials");
          return false;
        }

        // Commit this transaction to clear up held RMS/RMDBeans
        if (transaction != null && transaction.isActive())
          transaction.commit();

        // Get a new transaction
        transaction = storageManager.getTransaction();
      }

      //lookup a sender bean
      SenderBeanMgr senderBeanMgr = storageManager.getSenderBeanMgr();

      //selecting the set of SenderBeans that suit the given criteria.
      findSenderBean.setSend(true);
      findSenderBean.setTransportAvailable(false);

      if (address != null)
        findSenderBean.setToAddress(address);

      if (identifier != null) {
        if (LoggingControl.isAnyTracingEnabled() && log.isDebugEnabled())
          log.debug("identifier set, this violates RSP " + identifier);
        findSenderBean.setSequenceID(identifier.getIdentifier());
      }

      SenderBean senderBean = null;
      boolean pending = false;
      while (true) {
        // Set the time to send field to be now
        findSenderBean.setTimeToSend(System.currentTimeMillis());

        //finding the beans that go with the criteria of the passed SenderBean
        //The reSend flag is ignored for this selection, so there is no need to
        //set it.
        Collection<SenderBean> collection = senderBeanMgr.find(findSenderBean);

        //removing beans that does not pass the resend test
        for (Iterator<SenderBean> it = collection.iterator(); it.hasNext();) {
          SenderBean bean = (SenderBean) it.next();
          if (!bean.isReSend() && bean.getSentCount() > 0)
            it.remove();
        }

        //selecting a bean to send RANDOMLY. TODO- Should use a better mechanism.
        int size = collection.size();
        int itemToPick = -1;

        pending = false;
        if (size > 0) {
          Random random = new Random();
          itemToPick = random.nextInt(size);
        }

        if (size > 1)
          pending = true//there are more than one message to be delivered using the makeConnection.
        //So the MessagePending header should have value true;

        Iterator<SenderBean> it = collection.iterator();

        senderBean = null;
        for (int item = 0; item < size; item++) {
          senderBean = (SenderBean) it.next();
          if (item == itemToPick)
            break;
        }

        if (senderBean == null) {
          //If secured try another sequence
          //Remove old one from the list and pick another random one
          if (secured) {
            possibleBeans.remove(possibleBeanIndex);
            int possBeansSize = possibleBeans.size();

            if (possBeansSize > 0) {
              //select one at random: TODO better method?
              Random random = new Random();
              possibleBeanIndex = random.nextInt(possBeansSize);
              RMSequenceBean selectedSequence = (RMSequenceBean) possibleBeans.get(possibleBeanIndex);
              findSenderBean.setSequenceID(selectedSequence.getSequenceID());
              if (LoggingControl.isAnyTracingEnabled() && log.isDebugEnabled())
                log.debug("sequence selected " + findSenderBean.getSequenceID());
            } else {
              if (LoggingControl.isAnyTracingEnabled() && log.isDebugEnabled())
                log.debug("Exit: MakeConnectionProcessor::processInMessage, no matching message found");
View Full Code Here

Examples of org.apache.sandesha2.storage.beans.RMSequenceBean

    String sequenceId = closeSequence.getIdentifier().getIdentifier();
   
    StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(configCtx, configCtx
        .getAxisConfiguration());

    RMSequenceBean rmBean = SandeshaUtil.getRMDBeanFromSequenceId(storageManager, sequenceId);
    if(rmBean==null){
      rmBean = SandeshaUtil.getRMSBeanFromSequenceId(storageManager, sequenceId);
    }
   
    //check the security credentials
    SandeshaUtil.assertProofOfPossession(rmBean, msgCtx, msgCtx.getEnvelope().getBody());

    if (FaultManager.checkForUnknownSequence(rmMsgCtx, sequenceId, storageManager, false)) {
      if (log.isDebugEnabled())
        log.debug("Exit: CloseSequenceProcessor::processInMessage, Unknown sequence " + sequenceId);
      return false;
    }
   
    // throwing a fault if the sequence is terminated
    if (FaultManager.checkForSequenceTerminated(rmMsgCtx, sequenceId, rmBean, false)) {
      if (log.isDebugEnabled())
        log.debug("Exit: CloseSequenceProcessor::processInMessage, Sequence terminated");
      return false;
    }

    rmBean.setClosed(true);

    RMMsgContext closeSeqResponseRMMsg = RMMsgCreator.createCloseSeqResponseMsg(rmMsgCtx, rmBean);
    MessageContext closeSequenceResponseMsg = closeSeqResponseRMMsg.getMessageContext();   
    if(rmBean instanceof RMDBean){
      storageManager.getRMDBeanMgr().update((RMDBean)rmBean);
      //Piggyback an ack for the sequence being closed on the closeSequenceResponse
      RMMsgCreator.addAckMessage(closeSeqResponseRMMsg, sequenceId, (RMDBean)rmBean, false, true);
    }
    else{
      storageManager.getRMSBeanMgr().update((RMSBean)rmBean);
    }

    closeSeqResponseRMMsg.setFlow(MessageContext.OUT_FLOW);
    closeSeqResponseRMMsg.setProperty(Sandesha2Constants.APPLICATION_PROCESSING_DONE, "true");
    closeSequenceResponseMsg.setResponseWritten(true);
    if(rmBean instanceof RMSBean && rmBean.getRMVersion().equals(Sandesha2Constants.SPEC_VERSIONS.v1_1)){
      //we expect a response
      closeSequenceResponseMsg.setReplyTo(rmBean.getReplyToEndpointReference());
    }
    closeSeqResponseRMMsg.addSOAPEnvelope();
   
    //
    // Now that we have generated the message we can commit the transaction
View Full Code Here

Examples of org.apache.sandesha2.storage.beans.RMSequenceBean

   
    ConfigurationContext context = terminateSeqMsg.getConfigurationContext();
    StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(context,context.getAxisConfiguration());
   
    // Check that the sender of this TerminateSequence holds the correct token
    RMSequenceBean rmBean = SandeshaUtil.getRMDBeanFromSequenceId(storageManager, sequenceId);
    if(rmBean==null){
      rmBean = SandeshaUtil.getRMSBeanFromSequenceId(storageManager, sequenceId);
    }
   
    //check security credentials
    SandeshaUtil.assertProofOfPossession(rmBean, terminateSeqMsg,
        terminateSeqMsg.getEnvelope().getBody());

    if (FaultManager.checkForUnknownSequence(terminateSeqRMMsg, sequenceId, storageManager, false)) {
      if (log.isDebugEnabled())
        log.debug("Exit: TerminateSeqMsgProcessor::processInMessage, unknown sequence");
      return false;
    }

    // add the terminate sequence response if required.
    RMMsgContext terminateSequenceResponse = null;
    if (SpecSpecificConstants.isTerminateSequenceResponseRequired(terminateSeqRMMsg.getRMSpecVersion()))
      terminateSequenceResponse = getTerminateSequenceResponse(terminateSeqRMMsg, rmBean, sequenceId, storageManager);

    setUpHighestMsgNumbers(context, storageManager, sequenceId, terminateSeqRMMsg);
   
    boolean inOrderInvocation = SandeshaUtil.getDefaultPropertyBean(context.getAxisConfiguration()).isInOrder();
   
    //if the invocation is inOrder and if this is RM 1.1 there is a posibility of all the messages having aleady being invoked.
    //In this case we should do the full termination.
   
    boolean doFullTermination = false;
   
    if (inOrderInvocation && rmBean instanceof RMDBean) {

      long highestMsgNo = ((RMDBean)rmBean).getHighestInMessageNumber();
      long nextMsgToProcess = ((RMDBean)rmBean).getNextMsgNoToProcess();
     
      if (nextMsgToProcess>highestMsgNo) {
        //all the messages have been invoked, u can do the full termination
        doFullTermination = true;
      }
    } else {
      //for not-inorder case, always do the full termination.
      doFullTermination = true;
    }
   
    if (doFullTermination) {
      TerminateManager.cleanReceivingSideAfterInvocation(sequenceId, storageManager);
      TerminateManager.cleanReceivingSideOnTerminateMessage(context, sequenceId, storageManager);
    } else
      TerminateManager.cleanReceivingSideOnTerminateMessage(context, sequenceId, storageManager);

    rmBean.setTerminated(true);   
    rmBean.setLastActivatedTime(System.currentTimeMillis());
    if(rmBean instanceof RMDBean){
      storageManager.getRMDBeanMgr().update((RMDBean)rmBean);
    }
    else{
      storageManager.getRMSBeanMgr().update((RMSBean)rmBean);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.