Package org.apache.sandesha2.storage.beanmanagers

Examples of org.apache.sandesha2.storage.beanmanagers.InvokerBeanMgr


    Transaction transaction = null;

    try {
      RMDBeanMgr nextMsgMgr = storageManager.getRMDBeanMgr();

      InvokerBeanMgr storageMapMgr = storageManager
          .getInvokerBeanMgr();

      transaction = storageManager.getTransaction();
     
      // Pick a sequence using a round-robin approach
      ArrayList allSequencesList = getSequences();
      int size = allSequencesList.size();
      log.debug("Choosing one from " + size + " sequences");
      if(nextIndex >= size) {
        nextIndex = 0;

        // We just looped over the set of sequences. If we didn't process any
        // messages on this loop then we sleep before the next one
        if(size == 0 || !processedMessage) {
          sleep = true;
        }
        processedMessage = false;
       
        if (log.isDebugEnabled()) log.debug("Exit: Invoker::internalRun, looped over all sequences, sleep " + sleep);
       
        if(transaction != null && transaction.isActive()) transaction.commit();
        transaction = null;
       
        return sleep;
      }

      SequenceEntry entry = (SequenceEntry) allSequencesList.get(nextIndex++);
      String sequenceId = entry.getSequenceId();
      log.debug("Chose sequence " + sequenceId);

      RMDBean nextMsgBean = nextMsgMgr.retrieve(sequenceId);
      if (nextMsgBean == null) {
        log.debug("Next message not set correctly. Removing invalid entry.");

        stopThreadForSequence(sequenceId, entry.isRmSource());
        allSequencesList = getSequences();
        if (allSequencesList.size() == 0)
          sleep = true;

        if (log.isDebugEnabled()) log.debug("Exit: Invoker::internalRun, sleep " + sleep);
       
        if(transaction != null && transaction.isActive()) transaction.commit();
        transaction = null;

        return sleep;
      }

      long nextMsgno = nextMsgBean.getNextMsgNoToProcess();
      if (nextMsgno <= 0) {
        // Make sure we sleep on the next loop, so that we don't spin in a tight loop
        sleep = true;
        if (log.isDebugEnabled())
          log.debug("Invalid Next Message Number " + nextMsgno);
        String message = SandeshaMessageHelper.getMessage(
            SandeshaMessageKeys.invalidMsgNumber, Long
                .toString(nextMsgno));
        throw new SandeshaException(message);
      }

      InvokerBean selector = new InvokerBean();
      selector.setSequenceID(sequenceId);
      selector.setMsgNo(nextMsgno);
      List invokerBeans = storageMapMgr.find(selector);
     
      //add any msgs that belong to out of order windows
      addOutOfOrderInvokerBeansToList(sequenceId,
          storageManager, invokerBeans);
     
View Full Code Here


    MessageContext msgToInvoke = null;
   
    try {
     
      StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(configurationContext,configurationContext.getAxisConfiguration());
      InvokerBeanMgr invokerBeanMgr = storageManager.getInvokerBeanMgr();
     
      //starting a transaction
      transaction = storageManager.getTransaction();
     
      InvokerBean invokerBean = invokerBeanMgr.retrieve(messageContextKey);

      msgToInvoke = storageManager.retrieveMessageContext(messageContextKey, configurationContext);

      // ending the transaction before invocation.
      if(transaction != null) {
        transaction.commit();
        transaction = storageManager.getTransaction();
      }
     
      RMMsgContext rmMsg = MsgInitializer.initializeMessage(msgToInvoke);

      // Lock the RMD Bean just to avoid deadlocks
      SandeshaUtil.getRMDBeanFromSequenceId(storageManager, invokerBean.getSequenceID());
      // Depending on the transaction  support, the service will be invoked only once.
      // Therefore we delete the invoker bean and message now, ahead of time
      invokerBeanMgr.delete(messageContextKey);
      // removing the corresponding message context as well.
      storageManager.removeMessageContext(messageContextKey);

      try {
View Full Code Here

      if(backchannelFree && ackBackChannel) {
        result = InvocationResponse.ABORT;
      } else {
        result = InvocationResponse.SUSPEND;
      }
      InvokerBeanMgr storageMapMgr = storageManager.getInvokerBeanMgr();

      storageManager.storeMessageContext(key, rmMsgCtx.getMessageContext());
      InvokerBean invokerBean = new InvokerBean(key, msgNo, sequenceId);
     
      ContextManager contextMgr = SandeshaUtil.getContextManager(configCtx);
      if(contextMgr != null) invokerBean.setContext(contextMgr.storeContext());

      storageMapMgr.insert(invokerBean);

      // This will avoid performing application processing more than once.
      rmMsgCtx.setProperty(Sandesha2Constants.APPLICATION_PROCESSING_DONE, "true");

    }
View Full Code Here

   */
  public static void cleanReceivingSideAfterInvocation(String sequenceId,
      StorageManager storageManager) throws SandeshaException {
    if(log.isDebugEnabled()) log.debug("Enter: TerminateManager::cleanReceivingSideAfterInvocation " +sequenceId);
   
    InvokerBeanMgr invokerBeanMgr = storageManager.getInvokerBeanMgr();

    // removing InvokerBean entries
    InvokerBean invokerFindBean = new InvokerBean();
    invokerFindBean.setSequenceID(sequenceId);
    Collection collection = invokerBeanMgr.find(invokerFindBean);
    Iterator iterator = collection.iterator();
    while (iterator.hasNext()) {
      InvokerBean invokerBean = (InvokerBean) iterator.next();
      String messageStoreKey = invokerBean.getMessageContextRefKey();
      invokerBeanMgr.delete(messageStoreKey);

      // removing the respective message context from the message store.
      storageManager.removeMessageContext(messageStoreKey);
    }

View Full Code Here

      try {
        StorageManager storageManager = SandeshaUtil
            .getSandeshaStorageManager(context);
        NextMsgBeanMgr nextMsgMgr = storageManager.getNextMsgBeanMgr();

        InvokerBeanMgr storageMapMgr = storageManager
            .getStorageMapBeanMgr();

        SequencePropertyBeanMgr sequencePropMgr = storageManager
            .getSequencePropretyBeanMgr();

        Transaction preInvocationTransaction = storageManager.getTransaction();
       
        //Getting the incomingSequenceIdList
        SequencePropertyBean allSequencesBean = (SequencePropertyBean) sequencePropMgr
            .retrieve(
                Sandesha2Constants.SequenceProperties.ALL_SEQUENCES,
                Sandesha2Constants.SequenceProperties.INCOMING_SEQUENCE_LIST);
        if (allSequencesBean == null)
          continue;

        ArrayList allSequencesList = SandeshaUtil.getArrayListFromString (allSequencesBean
            .getValue());
       
        preInvocationTransaction.commit();
       
        Iterator allSequencesItr = allSequencesList.iterator();

        currentIteration: while (allSequencesItr.hasNext()) {

          String sequenceId = (String) allSequencesItr.next();
         
          Transaction invocationTransaction = storageManager.getTransaction();   //Transaction based invocation
         
          NextMsgBean nextMsgBean = nextMsgMgr.retrieve(sequenceId);
          if (nextMsgBean == null) {

            String message = "Next message not set correctly. Removing invalid entry.";
            log.debug(message);
            allSequencesItr.remove();
           
            //cleaning the invalid data of the all sequences.
            allSequencesBean.setValue(allSequencesList.toString());
            sequencePropMgr.update(allSequencesBean)
           
            throw new SandeshaException (message);
          }

          long nextMsgno = nextMsgBean.getNextMsgNoToProcess();
          if (nextMsgno <= 0) {
            String message = "Invalid messaage number as the Next Message Number. Removing invalid entry";
           
            throw new SandeshaException(message);
          }

          Iterator stMapIt = storageMapMgr.find(
              new InvokerBean(null, nextMsgno, sequenceId))
              .iterator();
         
          boolean invoked = false;
         
          while (stMapIt.hasNext()) {

            InvokerBean stMapBean = (InvokerBean) stMapIt
                .next();
            String key = stMapBean.getMessageContextRefKey();


            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
View Full Code Here

   * @param sequenceID
   * @throws SandeshaException
   */
  public static void cleanReceivingSideAfterInvocation (ConfigurationContext configContext, String sequenceID) throws SandeshaException {
    StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(configContext);
    InvokerBeanMgr storageMapBeanMgr = storageManager.getStorageMapBeanMgr();
       
    //removing storageMap entries
    InvokerBean findStorageMapBean = new InvokerBean ();
    findStorageMapBean.setSequenceID(sequenceID);
    findStorageMapBean.setInvoked(true);
    Collection collection = storageMapBeanMgr.find(findStorageMapBean);
    Iterator iterator = collection.iterator();
    while (iterator.hasNext()) {
      InvokerBean storageMapBean = (InvokerBean) iterator.next();
      storageMapBeanMgr.delete(storageMapBean.getMessageContextRefKey());
    }
   
    String cleanStatus = (String) receivingSideCleanMap.get(sequenceID);
    if (cleanStatus!=null && CLEANED_ON_TERMINATE_MSG.equals(cleanStatus))
      completeTerminationOfReceivingSide(configContext,sequenceID);
View Full Code Here

   * This has to be called by the lastly invocated one of the above two methods.
   *
   */
  private static void completeTerminationOfReceivingSide (ConfigurationContext configContext, String sequenceID) throws SandeshaException {
    StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(configContext);
    InvokerBeanMgr storageMapBeanMgr = storageManager.getStorageMapBeanMgr();
    NextMsgBeanMgr nextMsgBeanMgr = storageManager.getNextMsgBeanMgr();
   
    //removing nextMsgMgr entries
    NextMsgBean findNextMsgBean = new NextMsgBean ();
    findNextMsgBean.setSequenceID(sequenceID);
View Full Code Here

    NextMsgBean bean = mgr.retrieve(sequenceId);

    if (bean == null)
      throw new SandeshaException("Error- The sequence does not exist");

    InvokerBeanMgr storageMapMgr = storageManager.getStorageMapBeanMgr();
   
    //inorder invocation is still a global property
    boolean inOrderInvocation = SandeshaUtil.getPropertyBean(msgCtx.getConfigurationContext().getAxisConfiguration()).isInOrder();
   
    if (inOrderInvocation) {
     
      //pause the message
      rmMsgCtx.pause();
     
      SequencePropertyBean incomingSequenceListBean = (SequencePropertyBean) seqPropMgr
          .retrieve(
              Sandesha2Constants.SequenceProperties.ALL_SEQUENCES,
              Sandesha2Constants.SequenceProperties.INCOMING_SEQUENCE_LIST);

      if (incomingSequenceListBean == null) {
        ArrayList incomingSequenceList = new ArrayList();
        incomingSequenceListBean = new SequencePropertyBean();
        incomingSequenceListBean
            .setSequenceID(Sandesha2Constants.SequenceProperties.ALL_SEQUENCES);
        incomingSequenceListBean
            .setName(Sandesha2Constants.SequenceProperties.INCOMING_SEQUENCE_LIST);
        incomingSequenceListBean.setValue(incomingSequenceList
            .toString());

        seqPropMgr.insert(incomingSequenceListBean);
      }

      ArrayList incomingSequenceList = SandeshaUtil
          .getArrayListFromString(incomingSequenceListBean.getValue());

      //Adding current sequence to the incoming sequence List.
      if (!incomingSequenceList.contains(sequenceId)) {
        incomingSequenceList.add(sequenceId);

        //saving the property.
        incomingSequenceListBean.setValue(incomingSequenceList
            .toString());
        seqPropMgr.insert(incomingSequenceListBean);
      }

      //saving the message.
      try {
        storageManager.storeMessageContext(key,rmMsgCtx
            .getMessageContext());
        storageMapMgr.insert(new InvokerBean(key, msgNo, sequenceId));

        //This will avoid performing application processing more
        // than
        // once.
        rmMsgCtx.setProperty(
View Full Code Here

        finder.setMsgNo(messageNumber + 1);

        StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(configurationContext,configurationContext.getAxisConfiguration());
        tran = storageManager.getTransaction();

        InvokerBeanMgr mgr = storageManager.getInvokerBeanMgr();
        InvokerBean nextBean = mgr.findUnique(finder);

        if(nextBean != null) {
          if(pooledThread) {
            if(log.isDebugEnabled()) log.debug("InvokerWorker:: pooledThread");
            initializeFromBean(nextBean);
View Full Code Here

    }
   
    try {
     
      StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(configurationContext,configurationContext.getAxisConfiguration());
      InvokerBeanMgr invokerBeanMgr = storageManager.getInvokerBeanMgr();
     
      //starting a transaction
      if(tran == null) {
        transaction = storageManager.getTransaction();
      } else {
        transaction = tran;
      }
     
      InvokerBean invokerBean = invokerBeanMgr.retrieve(messageContextKey);

      msgToInvoke = storageManager.retrieveMessageContext(messageContextKey, configurationContext);
      if(msgToInvoke==null){
        //return since there is nothing to do
        if(log.isDebugEnabled()) log.debug("null msg");
        return false;
      }

      // ending the transaction before invocation.
      if(transaction != null) {
        transaction.commit();
        transaction = storageManager.getTransaction();
      }

      RMMsgContext rmMsg = MsgInitializer.initializeMessage(msgToInvoke);

      // Lock the RMD Bean just to avoid deadlocks
      RMDBean rMDBean = SandeshaUtil.getRMDBeanFromSequenceId(storageManager, invokerBean.getSequenceID());

      boolean highestMessage = false;

      if(!ignoreNextMsg){
        // updating the next msg to invoke
        long nextMsgNo = rMDBean.getNextMsgNoToProcess();
       
        if (!(invokerBean.getMsgNo()==nextMsgNo)) {
          //someone else has invoked this before us - this run should now stop
          if(log.isDebugEnabled()) log.debug("Operated message number is different from the Next Message Number to invoke");
          return false;
        }
       
        nextMsgNo++;
        rMDBean.setNextMsgNoToProcess(nextMsgNo);
        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();
            if (invokerBean.getMsgNo()==highestInMsgNo)
              highestMessage = true;
          }
        }
      }

      // Depending on the transaction  support, the service will be invoked only once.
      // Therefore we delete the invoker bean and message now, ahead of time
      invokerBeanMgr.delete(messageContextKey);
      // removing the corresponding message context as well.
      storageManager.removeMessageContext(messageContextKey);

      try {
View Full Code Here

TOP

Related Classes of org.apache.sandesha2.storage.beanmanagers.InvokerBeanMgr

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.