Package org.apache.sandesha2.storage

Examples of org.apache.sandesha2.storage.Transaction


    // Note that some messages (such as stand-alone acks) will be routed here, but
    // the headers will already have been processed. Therefore we should not assume
    // that we will have a MsgProcessor every time.
    MsgProcessor msgProcessor = MsgProcessorFactory.getMessageProcessor(rmMsgCtx);
    if(msgProcessor != null) {
      Transaction transaction = null;
     
      try {
        ConfigurationContext context = msgCtx.getConfigurationContext();
        StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(context, context.getAxisConfiguration());       
        transaction = storageManager.getTransaction();

        msgProcessor.processInMessage(rmMsgCtx, transaction);

        if(transaction != null && transaction.isActive()) transaction.commit();
          transaction = null;

      } catch (Exception e) {
        if (log.isDebugEnabled())
          log.debug("Exception caught during processInMessage", e);
        // message should not be sent in a exception situation.
        msgCtx.pause();
 
        if (!(e instanceof AxisFault)) {
          String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.inMsgError, e.toString());
          throw new AxisFault(message, e);
        }
       
        throw (AxisFault)e;
      } finally {
        if (transaction != null && transaction.isActive()) {
          try {
            transaction.rollback();
          } catch (Exception e1) {
            String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.rollbackError, e1.toString());
            log.debug(message, e1);
          }
        }
View Full Code Here


    super(POLLING_MANAGER_WAIT_TIME);
  }
 
  protected boolean internalRun() {
    if(log.isDebugEnabled()) log.debug("Enter: PollingManager::internalRun");
    Transaction t = null;
    try {
      // If we have request scheduled, handle them first, and then pick
      // pick a sequence using a round-robin approach. Scheduled polls
      // bypass the normal polling checks, to make sure that they happen
      boolean forcePoll = false;
      SequenceEntry entry = null;
      synchronized (this) {
        if(!scheduledPollingRequests.isEmpty()) {
          entry = (SequenceEntry) scheduledPollingRequests.removeFirst();
          forcePoll = true;
        }
      }
      if(entry == null) {
        ArrayList allSequencesList = getSequences();
        int size = allSequencesList.size();
        if(log.isDebugEnabled()) log.debug("Choosing one from " + size + " sequences");
        if(nextIndex >= size) {
          nextIndex = 0;
          // We just looped over the set of sequences, so sleep before we try
          // polling them again.
          if (log.isDebugEnabled()) log.debug("Exit: PollingManager::internalRun, looped over all sequences, sleeping");
          return true;
        }
 
        entry = (SequenceEntry) allSequencesList.get(nextIndex++);
       
        long now = System.currentTimeMillis();
        Long time = (Long) pollTimes.get(entry.getSequenceId());
        if(time != null && (now - time.longValue()) < POLLING_MANAGER_WAIT_TIME) {
          // We have polled for this sequence too recently, so skip over this one
          if (log.isDebugEnabled()) log.debug("Exit: PollingManager::internalRun, skipping sequence, not sleeping");
          return false;
        }
        pollTimes.put(entry.getSequenceId(), new Long(now));
       
      }
      if(log.isDebugEnabled()) log.debug("Chose sequence " + entry.getSequenceId());

      t = storageManager.getTransaction();
      if(entry.isRmSource()) {
        pollRMSSide(entry, forcePoll);
      } else {
        pollRMDSide(entry, forcePoll);
      }
      if(t != null) t.commit();
      t = null;

    } catch (Exception e) {
      if(log.isDebugEnabled()) log.debug("Exception", e);
    } finally {
      if(t != null && t.isActive()) {
        try {
          t.rollback();
        } catch(Exception e2) {
          if(log.isDebugEnabled()) log.debug("Exception during rollback", e2);
        }
      }
    }
View Full Code Here

   */
  public static void forceDispatchOfInboundMessages(ConfigurationContext configContext,
      String sequenceID,
      boolean allowLaterDeliveryOfMissingMessages)throws SandeshaException{

    Transaction reportTransaction = null;

    try {
      StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(configContext, configContext.getAxisConfiguration());
      reportTransaction = storageManager.getTransaction();

      //only do this if we are running inOrder
      if(SandeshaUtil.getPropertyBean(configContext.getAxisConfiguration()).isInOrder()){
        Invoker invoker = (Invoker)SandeshaUtil.getSandeshaStorageManager(configContext, configContext.getAxisConfiguration()).getInvoker();
        if (invoker==null){
          throw new SandeshaException(SandeshaMessageHelper.getMessage(
            SandeshaMessageKeys.invokerNotFound, sequenceID));
        }
       
        invoker.forceInvokeOfAllMessagesCurrentlyOnSequence(configContext, sequenceID, allowLaterDeliveryOfMissingMessages);     
      }
     
      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();
    }
  }
View Full Code Here

    }

    StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(configurationContext,configurationContext.getAxisConfiguration());
   
    // Get a transaction for getting the sequence properties
    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

  public Transaction getTransaction() {
    // Calling getTransaction is the only way to set up a new transaction. If you
    // do some work that requires a tran without there being a transaction in scope
    // then the enlist method will throw an exception.
    Transaction result = null;
    synchronized (transactions) {
      Thread key = Thread.currentThread();
      String name = key.getName();
      int    id = System.identityHashCode(key);
      result = (Transaction) transactions.get(key);
View Full Code Here

  public static SequenceReport getIncomingSequenceReport(String sequenceID, ConfigurationContext configCtx)
      throws SandeshaException {

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

    Transaction reportTransaction = null;

    try {
      reportTransaction = storageManager.getTransaction();

      SequenceReport sequenceReport = new SequenceReport();

      RMDBean rmdBean = SandeshaUtil.getRMDBeanFromSequenceId(storageManager, sequenceID);

      List completedMessageList = rmdBean.getServerCompletedMessages().getContainedElementsAsNumbersList();
     
      Iterator iter = completedMessageList.iterator();
      while (iter.hasNext()) {
        sequenceReport.addCompletedMessage((Long) iter.next());
      }

      sequenceReport.setSequenceID(sequenceID);
      sequenceReport.setInternalSequenceID(sequenceID); // for the
                                // incoming side
                                // internalSequenceID=sequenceID
      sequenceReport.setSequenceDirection(SequenceReport.SEQUENCE_DIRECTION_IN);

      sequenceReport.setSequenceStatus(getServerSequenceStatus(sequenceID, storageManager));

      if(rmdBean.getSecurityTokenData() != null) sequenceReport.setSecureSequence(true);
     
      if (reportTransaction!=null && reportTransaction.isActive()) reportTransaction.commit();
      reportTransaction = null;

      return sequenceReport;

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

    return null;
  }
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

    ConfigurationContext configurationContext = serviceContext.getConfigurationContext();

    // Get the in use storage manager and the sequence property bean manager
    StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(configurationContext,configurationContext.getAxisConfiguration());
   
    Transaction transaction = null;
    Exception resultException = null;
   
    try
    {
      transaction = storageManager.getTransaction();
      RMSBean bean = SandeshaUtil.getRMSBeanFromInternalSequenceId(storageManager, internalSequenceId);
     
      if (bean != null) {           
        resultException = bean.getLastSendError();
      }
    }
    finally
    {
      // Commit the tran whatever happened
      if(transaction != null) transaction.commit();
    }
   
    if (log.isDebugEnabled())
      log.debug("Exit: SandeshaClient::getLastSendError, " + resultException);
   
View Full Code Here

    // Get the in use storage manager and the sequence property bean manager
    StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(configurationContext,configurationContext.getAxisConfiguration());
   
    // Create a transaction for the retrieve operation
    Transaction transaction = null;
    long resultTime = -1;

    try
    {
      transaction = storageManager.getTransaction();
     
      RMSBean bean = SandeshaUtil.getRMSBeanFromInternalSequenceId(storageManager, internalSequenceId);
     
      if (bean != null) {           
        resultTime = bean.getLastSendErrorTimestamp();
      }
    }
    finally
    {
      // commit the transaction as it was only a retrieve
      if(transaction != null) transaction.commit();
    }
   
    if (log.isDebugEnabled())
      log.debug("Exit: SandeshaClient::getLastSendErrorTimestamp, " + resultTime);
   
View Full Code Here

  private static final String getSOAPNamespaceURI(StorageManager storageManager, String internalSequenceID) throws SandeshaException {
    String soapNamespaceURI = null;
   
    // Get the RMSBean for this sequence.
    Transaction transaction = null;
   
    try {
      transaction = storageManager.getTransaction();
      RMSBean rmsBean = SandeshaUtil.getRMSBeanFromInternalSequenceId(storageManager, internalSequenceID);
      if (rmsBean.getSoapVersion() == Sandesha2Constants.SOAPVersion.v1_2)
        soapNamespaceURI = SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI;
    } finally {
      if(transaction != null) transaction.commit();
    }
   
    return soapNamespaceURI;
  }
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.