Package org.apache.sandesha2.storage

Examples of org.apache.sandesha2.storage.Transaction


    StorageManager storageManager =
      SandeshaUtil.getSandeshaStorageManager(rmMsgCtx.getConfigurationContext(),
          rmMsgCtx.getConfigurationContext().getAxisConfiguration());
   
    Transaction transaction = null;
   
    try {
      transaction = storageManager.getTransaction();
   
      // 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(rmMsgCtx.getConfigurationContext());
       
        QName seqName = new QName(rmMsgCtx.getRMNamespaceValue(), Sandesha2Constants.WSRM_COMMON.SEQUENCE);
       
        SOAPEnvelope envelope = rmMsgCtx.getSOAPEnvelope();
        OMElement body = envelope.getBody();
        OMElement seqHeader = envelope.getHeader().getFirstChildWithName(seqName);
       
        SecurityToken token = secManager.recoverSecurityToken(bean.getSecurityTokenData());
       
        secManager.checkProofOfPossession(token, seqHeader, rmMsgCtx.getMessageContext());
        secManager.checkProofOfPossession(token, body, rmMsgCtx.getMessageContext());
      }
     
      MessageContext messageContext = rmMsgCtx.getMessageContext();
   
      if (bean != null) {
       
        if (msgNo == 0) {
          String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.invalidMsgNumber, Long
              .toString(msgNo));
          log.debug(message);
          throw new SandeshaException(message);
        }
   
        // Get 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));
         
          storageManager.getRMDBeanMgr().update(bean);
        }
        else {
          
          if (log.isDebugEnabled())
              log.debug("Detected duplicate message " + msgNo);
           
          boolean isDuplicate = true;
          //still allow this msg if we have no corresponding invoker bean for it and we are inOrder
          boolean isInOrder =
            SandeshaUtil.getDefaultPropertyBean(rmMsgCtx.getConfigurationContext().getAxisConfiguration()).isInOrder();
          if(isInOrder)
          {
            InvokerBean finderBean = new InvokerBean();
            finderBean.setMsgNo(msgNo);
            finderBean.setSequenceID(sequenceId);
            List invokerBeanList = storageManager.getInvokerBeanMgr().find(finderBean);
            if((invokerBeanList==null || invokerBeanList.size()==0)
                && bean.getNextMsgNoToProcess()<=msgNo){
              isDuplicate = false;
              if (log.isDebugEnabled())
                log.debug("Allowing completed message on sequence " + sequenceId + ", msgNo " + msgNo);
            }
          }
         
          if(isDuplicate){
            // Add the duplicate RM AxisOperation to the message
           
            //If the service has not been found by this time, we cannot proceed.
            AxisService service = rmMsgCtx.getMessageContext().getAxisService();
            if (service==null)
              throw new SandeshaException ("Duplicate message detected. But cant dispatch since the Service has not been found");
           
            setupDuplicateOperation(rmMsgCtx);           
          }
           
        }
      } else {
       
        if (log.isDebugEnabled())
            log.debug("Detected message for no sequence " + msgNo);
          messageContext.setRelationships(null);
          // Add the duplicate RM AxisOperation to the message

          //If the service has not been found by this time, we cannot proceed.
          AxisService service = rmMsgCtx.getMessageContext().getAxisService();
          if (service==null)
            throw new SandeshaException ("Duplicate message detected. But cant dispatch since the Service has not been found");
         
          setupDuplicateOperation(rmMsgCtx);  
      }
     
      if(transaction != null && transaction.isActive()) transaction.commit();
      transaction = null;
    }
    finally {
      if (transaction != null && transaction.isActive())
        transaction.rollback();
    }
    if (log.isDebugEnabled())
      log.debug("Exit: SandeshaGlobalInHandler::processApplicationMessage");
  }
View Full Code Here


        InvokerBean selector = new InvokerBean();
        selector.setSequenceID(sequenceID);
        Iterator stMapIt = storageMapMgr.find(selector).iterator();
       
        long highestMsgNumberInvoked = 0;
        Transaction transaction = null;
       
        //invoke each bean in turn.
        //NOTE: here we are breaking ordering
        while(stMapIt.hasNext()){
          //invoke the app
          try{
            transaction = storageManager.getTransaction();
            InvokerBean invoker = (InvokerBean)stMapIt.next();
           
            // start a new worker thread and let it do the invocation.
            String workId = sequenceID + "::" + invoker.getMsgNo(); //creating a workId to uniquely identify the
             //piece of work that will be assigned to the Worker.
           
            String messageContextKey = invoker.getMessageContextRefKey();
            InvokerWorker worker = new InvokerWorker(context,
                messageContextKey,
                true); //want to ignore the enxt msg number
           
            worker.setLock(getWorkerLock());
            worker.setWorkId(workId);
           
            // Wrap the invoker worker with the correct context, if needed.
            Runnable work = worker;
            ContextManager contextMgr = SandeshaUtil.getContextManager(context);
            if(contextMgr != null) {
              work = contextMgr.wrapWithContext(work, invoker.getContext());
            }
           
            threadPool.execute(work);
         
            //adding the workId to the lock after assigning it to a thread makes sure
            //that all the workIds in the Lock are handled by threads.
            getWorkerLock().addWork(workId);

            long msgNumber = invoker.getMsgNo();
            //if necessary, update the "next message number" bean under this transaction
            if(msgNumber>highestMsgNumberInvoked){
              highestMsgNumberInvoked = invoker.getMsgNo();
              rMDBean.setNextMsgNoToProcess(highestMsgNumberInvoked+1);
             
              if(allowLaterDeliveryOfMissingMessages){
                //we also need to update the sequence OUT_OF_ORDER_RANGES property
                //so as to include our latest view of this outOfOrder range.
                //We do that here (rather than once at the end) so that we reamin
                //transactionally consistent
                Range r = new Range(firstMessageInOutOfOrderWindow,highestMsgNumberInvoked);
                   
                RangeString rangeString = null;
                if(rMDBean.getOutOfOrderRanges()==null){
                  //insert a new blank one one
                  rangeString = new RangeString();
                }
                else{
                  rangeString = rMDBean.getOutOfOrderRanges();
                }
                //update the range String with the new value
                rangeString.addRange(r);
                rMDBean.setOutOfOrderRanges(rangeString);
              }
             
              rmdBeanMgr.update(rMDBean);
            }
           
            if(transaction != null && transaction.isActive()) transaction.commit();
            transaction = null;
          }
          catch(Exception e){
            // Just log the error
            if(log.isDebugEnabled()) log.debug("Exception", e);
          } finally {
            if(transaction != null && transaction.isActive()) {
              transaction.rollback();
              transaction = null;
            }
          }
   
        }//end while
View Full Code Here

 
  protected boolean internalRun() {
    if (log.isDebugEnabled()) log.debug("Enter: Invoker::internalRun");
   
    boolean sleep = false;
    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);
     
      // If there aren't any beans to process then move on to the next sequence
      if (invokerBeans.size() == 0) {
        if (log.isDebugEnabled()) log.debug("Exit: Invoker::internalRun, no beans to invoke on sequence " + sequenceId + ", sleep " + sleep);
       
        if(transaction != null && transaction.isActive()) transaction.commit();
        transaction = null;

        return sleep;
      }
     
      Iterator stMapIt = invokerBeans.iterator();

      //TODO correct the locking mechanism to have one lock per sequence.
      //TODO should this be a while, not an if?
      if (stMapIt.hasNext()) { //some invokation work is present
       
        InvokerBean bean = (InvokerBean) stMapIt.next();
        //see if this is an out of order msg
        boolean beanIsOutOfOrderMsg = bean.getMsgNo()!=nextMsgno;
       
        String workId = sequenceId + "::" + bean.getMsgNo();
                                  //creating a workId to uniquely identify the
                                 //piece of work that will be assigned to the Worker.
                 
        //check whether the bean is already assigned to a worker.
        if (getWorkerLock().isWorkPresent(workId)) {
          // As there is already a worker assigned we are probably dispatching
          // messages too quickly, so we sleep before trying the next sequence.
          sleep = true;
          String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.workAlreadyAssigned, workId);
          if (log.isDebugEnabled()) log.debug("Exit: Invoker::internalRun, " + message + ", sleep " + sleep);
         
          if(transaction != null) {
            transaction.commit();
            transaction = null;
          }
         
          return sleep;
        }

        String messageContextKey = bean.getMessageContextRefKey();
       
        if(transaction != null) {
          transaction.commit();
          transaction = null;
        }

        // start a new worker thread and let it do the invocation.
        InvokerWorker worker = new InvokerWorker(context,
            messageContextKey,
            beanIsOutOfOrderMsg); //only ignore nextMsgNumber if the bean is an
                                  //out of order message
       
        worker.setLock(getWorkerLock());
        worker.setWorkId(workId);
       
        // Wrap the invoker worker with the correct context, if needed.
        Runnable work = worker;
        ContextManager contextMgr = SandeshaUtil.getContextManager(context);
        if(contextMgr != null) {
          work = contextMgr.wrapWithContext(work, bean.getContext());
        }
        threadPool.execute(work);
       
        //adding the workId to the lock after assigning it to a thread makes sure
        //that all the workIds in the Lock are handled by threads.
        getWorkerLock().addWork(workId);
       
        processedMessage = true;
      }
     
      if(transaction != null && transaction.isActive()) transaction.commit();
      transaction = null;
    } catch (Exception e) {
      String message = SandeshaMessageHelper
          .getMessage(SandeshaMessageKeys.invokeMsgError);
      if(log.isDebugEnabled()) log.debug(message, e);
    } finally {
      if (transaction != null && transaction.isActive()) {
        try {
          transaction.rollback();
        } catch (Exception e) {
          String message = SandeshaMessageHelper.getMessage(
              SandeshaMessageKeys.rollbackError, e.toString());
          if(log.isDebugEnabled()) log.debug(message, e);
        }
View Full Code Here

   
    ConfigurationContext configurationContext = msgContext.getConfigurationContext();
    RMMsgContext rmmsgContext = MsgInitializer.initializeMessage(msgContext);
    StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(configurationContext, configurationContext.getAxisConfiguration());
   
    Transaction transaction = storageManager.getTransaction();
   
    AxisService service = null;
    try {
      String sequenceID = (String) rmmsgContext
          .getProperty(Sandesha2Constants.MessageContextProperties.SEQUENCE_ID);
      service = null;
      if (sequenceID != null) {

        //If this is the RMD of the sequence        
        RMDBean rmdBean = SandeshaUtil.getRMDBeanFromSequenceId(storageManager, sequenceID);
        if (rmdBean != null) {
                                        String serviceName = null;
                                        if (rmdBean != null ) {
                                                serviceName = rmdBean.getServiceName();
                                        }

          if (serviceName != null) {
            service = configurationContext.getAxisConfiguration()
                .getService(serviceName);
          }
        }

        if (service == null && rmdBean == null) {
          //If this is the RMS of the sequence
          RMSBean rmsBean = SandeshaUtil.getRMSBeanFromSequenceId(storageManager, sequenceID);

          if(rmsBean != null){
            String serviceName = rmsBean.getServiceName();
            if (serviceName != null) {
              service = configurationContext.getAxisConfiguration()
                  .getService(serviceName);
            }
          }
        }

      }
    } finally  {
      if (transaction != null && transaction.isActive())
        transaction.commit();
    }   
   
    if (log.isDebugEnabled())
      log.debug("Exit: SequenceIDDispatcher::findService, " + service);
    return service;
View Full Code Here

  }
 
  public void run() {
    if(log.isDebugEnabled()) log.debug("Enter: InvokerWorker::run");
   
    Transaction transaction = null;
    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 {

        boolean postFailureInvocation = false;

        // StorageManagers should st following property to
        // true, to indicate that the message received comes
        // after a failure.
        String postFaulureProperty = (String) msgToInvoke
            .getProperty(Sandesha2Constants.POST_FAILURE_MESSAGE);
        if (postFaulureProperty != null
            && Sandesha2Constants.VALUE_TRUE.equals(postFaulureProperty))
          postFailureInvocation = true;

        if (postFailureInvocation) {
          makeMessageReadyForReinjection(msgToInvoke);
          if (log.isDebugEnabled())
            log.debug("Receiving message, key=" + messageContextKey + ", msgCtx="
                + msgToInvoke.getEnvelope().getHeader());
          AxisEngine.receive(msgToInvoke);
        } else {
          if (log.isDebugEnabled())
            log.debug("Resuming message, key=" + messageContextKey + ", msgCtx="
                + msgToInvoke.getEnvelope().getHeader());
          msgToInvoke.setPaused(false);
          AxisEngine.resumeReceive(msgToInvoke);
        }
       
        if (transaction != null && transaction.isActive()){
          transaction.commit();
        }
      } catch (Exception e) {
        if (log.isDebugEnabled())
          log.debug("Exception :", e);
       
          if (transaction != null && transaction.isActive()){
              transaction.rollback();           
          }
          handleFault(rmMsg, e);
      }


      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());
         
          if (rmdBean!=null && rmdBean.isTerminated()) {
            long highestInMsgNo = rmdBean.getHighestInMessageNumber();
            if (invokerBean.getMsgNo()==highestInMsgNo)
              highestMessage = true;
          }
        }
       
        if (highestMessage) {
          //do cleaning stuff that hs to be done after the invocation of the last message.
          TerminateManager.cleanReceivingSideAfterInvocation(invokerBean.getSequenceID(), storageManager);
          // exit from current iteration. (since an entry
          // was removed)
          if(log.isDebugEnabled()) log.debug("Exit: InvokerWorker::run Last message return")
          if(transaction != null && transaction.isActive()) transaction.commit();
          return;
        }
      }
     
      if(!ignoreNextMsg){
        // updating the next msg to invoke
        RMDBean rMDBean = storageManager.getRMDBeanMgr().retrieve(invokerBean.getSequenceID());
        long nextMsgNo = rMDBean.getNextMsgNoToProcess();
       
        if (!(invokerBean.getMsgNo()==nextMsgNo)) {
          String message = "Operated message number is different from the Next Message Number to invoke";
          throw new SandeshaException (message);
        }
       
        nextMsgNo++;
        rMDBean.setNextMsgNoToProcess(nextMsgNo);
        storageManager.getRMDBeanMgr().update(rMDBean);
      }
     
      if(transaction != null && transaction.isActive()) transaction.commit();
      transaction = null;
     
    } catch (Exception e) {
      if (log.isErrorEnabled())
        log.error(e.toString(), e);
    } finally {
      if (workId !=null && lock!=null) {
        lock.removeWork(workId);
      }

      if (transaction!=null && transaction.isActive()) {
        try {
          transaction.rollback();
        } catch (SandeshaStorageException e) {
          if (log.isWarnEnabled())
            log.warn("Caught exception rolling back transaction", e);
        }
      }
View Full Code Here

    sequenceReport.setSequenceDirection(SequenceReport.SEQUENCE_DIRECTION_OUT);

    StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(configurationContext,configurationContext.getAxisConfiguration());
    RMSBeanMgr createSeqMgr = storageManager.getRMSBeanMgr();

    Transaction reportTransaction = null;

    try {
      if (createTransaction)
        reportTransaction = storageManager.getTransaction();

      sequenceReport.setInternalSequenceID(internalSequenceID);

      RMSBean createSeqFindBean = new RMSBean();
      createSeqFindBean.setInternalSequenceID(internalSequenceID);

      RMSBean rMSBean = createSeqMgr.findUnique(createSeqFindBean);

      // if data not is available sequence has to be terminated or
      // timedOut.
      if (rMSBean != null && rMSBean.isTerminated()) {

        // check weather this is an terminated sequence.
        sequenceReport.setSequenceStatus(SequenceReport.SEQUENCE_STATUS_TERMINATED);

        fillOutgoingSequenceInfo(sequenceReport, rMSBean, storageManager);

        return sequenceReport;

      } else if (rMSBean != null && rMSBean.isTimedOut()) {

        sequenceReport.setSequenceStatus(SequenceReport.SEQUENCE_STATUS_TIMED_OUT);
       
        fillOutgoingSequenceInfo(sequenceReport, rMSBean, storageManager);

        return sequenceReport;
       
      } else if (rMSBean == null) {

        // sequence must hv been timed out before establishing. No other
        // posibility I can think of.
        // this does not get recorded since there is no key (which is
        // normally the sequenceID) to store it.

        // so, setting the sequence status to INITIAL
        sequenceReport.setSequenceStatus(SequenceReport.SEQUENCE_STATUS_INITIAL);

        // returning the current sequence report.
        return sequenceReport;
      }

      String outSequenceID = rMSBean.getSequenceID();
      if (outSequenceID == null) {
        sequenceReport.setInternalSequenceID(internalSequenceID);
        sequenceReport.setSequenceStatus(SequenceReport.SEQUENCE_STATUS_INITIAL);
        sequenceReport.setSequenceDirection(SequenceReport.SEQUENCE_DIRECTION_OUT);
        if(rMSBean.getSecurityTokenData() != null) sequenceReport.setSecureSequence(true);

        return sequenceReport;
      }

      sequenceReport.setSequenceStatus(SequenceReport.SEQUENCE_STATUS_ESTABLISHED);
      fillOutgoingSequenceInfo(sequenceReport, rMSBean, storageManager);
     
      if(reportTransaction != null && reportTransaction.isActive()) reportTransaction.commit();
      reportTransaction = null;

    } catch (Exception e) {
      // Just log the exception
      if(log.isDebugEnabled()) log.debug("Exception", e);
    } finally {
      if (reportTransaction!=null && reportTransaction.isActive()) reportTransaction.rollback();
    }

    return sequenceReport;
  }
View Full Code Here

  public static SandeshaReport getSandeshaReport(ConfigurationContext configurationContext) throws SandeshaException {

    StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(configurationContext,configurationContext.getAxisConfiguration());
    SandeshaReport sandeshaReport = new SandeshaReport();

    Transaction reportTransaction = null;

    try {
      reportTransaction = storageManager.getTransaction();

      List rmsBeans = storageManager.getRMSBeanMgr().find(null);
      Iterator iterator = rmsBeans.iterator();
      while (iterator.hasNext()) {
        RMSBean bean = (RMSBean) iterator.next();
        String sequenceID = bean.getSequenceID();
        sandeshaReport.addToOutgoingSequenceList(sequenceID);
        sandeshaReport.addToOutgoingInternalSequenceMap(sequenceID, bean.getInternalSequenceID());

        SequenceReport report = getOutgoingSequenceReport(bean.getInternalSequenceID(), configurationContext);

        sandeshaReport.addToNoOfCompletedMessagesMap(sequenceID, report.getCompletedMessages().size());
        sandeshaReport.addToSequenceStatusMap(sequenceID, report.getSequenceStatus());
      }

      // incoming sequences
      Collection rmdBeans = storageManager.getRMDBeanMgr().find(null);

      Iterator iter = rmdBeans.iterator();
      while (iter.hasNext()) {
        RMDBean serverCompletedMsgsBean = (RMDBean) iter.next();
        String sequenceID = serverCompletedMsgsBean.getSequenceID();
        sandeshaReport.addToIncomingSequenceList(sequenceID);

        SequenceReport sequenceReport = getIncomingSequenceReport(sequenceID, configurationContext);

        sandeshaReport.addToNoOfCompletedMessagesMap(sequenceID, sequenceReport.getCompletedMessages().size());
        sandeshaReport.addToSequenceStatusMap(sequenceID, sequenceReport.getSequenceStatus());
      }
     
      if(reportTransaction != null && reportTransaction.isActive()) reportTransaction.commit();
      reportTransaction = null;

    } catch (Exception e) {
      // just log the error
      if(log.isDebugEnabled()) log.debug("Exception", e);
    } finally {
      if (reportTransaction!=null && reportTransaction.isActive()) reportTransaction.rollback();
    }

    return sandeshaReport;
  }
View Full Code Here

    String internalSequenceId = SandeshaUtil.getInternalSequenceID(to, sequenceKey);
   
    if (log.isTraceEnabled())
      log.trace("Checking if sequence " + internalSequenceId + " previously terminated");
   
    Transaction tran = null;
   
    try {
      tran = storageManager.getTransaction();
     
      RMSBean rmsBean = SandeshaUtil.getRMSBeanFromInternalSequenceId(storageManager, internalSequenceId);
      //see if the sequence is terminated
      boolean terminatedSequence = false;
      if (rmsBean != null && rmsBean.isTerminated())
        terminatedSequence = true;
 
      //see if the sequence is timed out
      if(rmsBean != null && rmsBean.isTimedOut()){
        terminatedSequence = true;
      }
 
      if (terminatedSequence) {   
        // Delete the rmsBean
        storageManager.getRMSBeanMgr().delete(rmsBean.getCreateSeqMsgID());
      }
     
      if(tran != null && tran.isActive()) tran.commit();
      tran = null;
   
    } finally {
      if(tran!=null && tran.isActive())
        tran.rollback();
    }
  }
View Full Code Here

    }

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

    // Get a transaction to retrieve the properties
    Transaction transaction = null;
    String sequenceID = null;
   
    try
    {
      transaction = storageManager.getTransaction();
      sequenceID = SandeshaUtil.getSequenceIDFromInternalSequenceID(internalSequenceID, storageManager);   
    }
    finally
    {
      // Commit the transaction as it was only a retrieve
      if(transaction != null) transaction.commit();
    }
   
    if (sequenceID == null)
      throw new SandeshaException(SandeshaMessageHelper.getMessage(
          SandeshaMessageKeys.sequenceIdBeanNotSet));
View Full Code Here

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

    // Get a transaction to obtain sequence information
    Transaction transaction = null;
    String sequenceID = null;
   
    try
    {
      transaction = storageManager.getTransaction();
      sequenceID = SandeshaUtil.getSequenceIDFromInternalSequenceID(internalSequenceID, storageManager);
    }
    finally
    {
      // Commit the tran whatever happened
      if(transaction != null) transaction.commit();
    }
   
    if (sequenceID == null)
      sequenceID = Sandesha2Constants.TEMP_SEQUENCE_ID; 
   
View Full Code Here

TOP

Related Classes of org.apache.sandesha2.storage.Transaction

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.