Package org.apache.sandesha2.storage.beanmanagers

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


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

    // removing InvokerBean entries
    InvokerBean invokerFindBean = new InvokerBean();
    invokerFindBean.setSequenceID(sequenceId);
    Collection<InvokerBean> collection = invokerBeanMgr.find(invokerFindBean);
    Iterator<InvokerBean> 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


//    //first we block while we wait for the invoking thread to pause
//    blockForPause();
    try{
      StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(ctx, ctx.getAxisConfiguration());
      //get all invoker beans for the sequence
      InvokerBeanMgr storageMapMgr = storageManager
          .getInvokerBeanMgr();
      RMDBeanMgr rmdBeanMgr = storageManager.getRMDBeanMgr();
      RMDBean rMDBean = rmdBeanMgr.retrieve(sequenceID);
     
      if (rMDBean != null) {
       
        //The outOfOrder window is the set of known sequence messages (including those
        //that are missing) at the time the button is pressed.
        long firstMessageInOutOfOrderWindow = rMDBean.getNextMsgNoToProcess();
     
        InvokerBean selector = new InvokerBean();
        selector.setSequenceID(sequenceID);
        Iterator<InvokerBean> stMapIt = storageMapMgr.find(selector).iterator();
       
        long highestMsgNumberInvoked = 0;
        Transaction transaction = null;
       
        //invoke each bean in turn.
View Full Code Here

    Transaction transaction = null;

    try {
      RMDBeanMgr nextMsgMgr = storageManager.getRMDBeanMgr();

      InvokerBeanMgr storageMapMgr = storageManager
          .getInvokerBeanMgr();

      transaction = storageManager.getTransaction();
     
      // Pick a sequence using a round-robin approach
      ArrayList<SequenceEntry> 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<InvokerBean> invokerBeans = storageMapMgr.find(selector);
     
      //add any msgs that belong to out of order windows
      addOutOfOrderInvokerBeansToList(sequenceId,
          storageManager, invokerBeans);
     
View Full Code Here

   * @throws SandeshaException
   */
  public static void terminateAfterInvocation (ConfigurationContext configContext, String sequenceID) throws SandeshaException {
    StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(configContext);
    SequencePropertyBeanMgr sequencePropertyBeanMgr = storageManager.getSequencePropretyBeanMgr();
    InvokerBeanMgr storageMapBeanMgr = storageManager.getStorageMapBeanMgr();

    //removing storageMap entries
    InvokerBean findStorageMapBean = new InvokerBean ();
    findStorageMapBean.setSequenceId(sequenceID);
    Collection collection = storageMapBeanMgr.find(findStorageMapBean);
    Iterator iterator = collection.iterator();
    while (iterator.hasNext()) {
      InvokerBean storageMapBean = (InvokerBean) iterator.next();
      storageMapBeanMgr.delete(storageMapBean.getKey());
    }
   
    SequencePropertyBean allSequenceBean = sequencePropertyBeanMgr.retrieve(Sandesha2Constants.SequenceProperties.ALL_SEQUENCES,Sandesha2Constants.SequenceProperties.INCOMING_SEQUENCE_LIST);
    ArrayList allSequenceList = (ArrayList) allSequenceBean.getValue();
   
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();

    long nextMsgno = bean.getNextMsgNoToProcess();

    if (msgCtx.isServerSide()) {
      boolean inOrderInvocation = PropertyManager.getInstance().isInOrderInvocation();
      if (inOrderInvocation) {
        //pause the message
        msgCtx.setPausedTrue(new QName(Sandesha2Constants.IN_HANDLER_NAME));

        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);

          seqPropMgr.insert(incomingSequenceListBean);
        }

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

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

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

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

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

        InvokerBeanMgr storageMapMgr = storageManager
            .getStorageMapBeanMgr();

        SequencePropertyBeanMgr sequencePropMgr = storageManager
            .getSequencePropretyBeanMgr();

        //Getting the incomingSequenceIdList
        SequencePropertyBean sequencePropertyBean = (SequencePropertyBean) sequencePropMgr
            .retrieve(
                Sandesha2Constants.SequenceProperties.ALL_SEQUENCES,
                Sandesha2Constants.SequenceProperties.INCOMING_SEQUENCE_LIST);
        if (sequencePropertyBean == null)
          continue;

        ArrayList seqPropList = (ArrayList) sequencePropertyBean
            .getValue();
        Iterator seqPropIt = seqPropList.iterator();

        currentIteration: while (seqPropIt.hasNext()) {

          String sequenceId = (String) seqPropIt.next();

          NextMsgBean nextMsgBean = nextMsgMgr.retrieve(sequenceId);
          if (nextMsgBean == null)
            throw new SandeshaException(
                "Next message not set correctly");

          long nextMsgno = nextMsgBean.getNextMsgNoToProcess();
          if (nextMsgno <= 0)
            throw new SandeshaException(
                "Invalid messaage number for the nextMsgNo");

          Iterator stMapIt = storageMapMgr.find(
              new InvokerBean(null, nextMsgno, sequenceId))
              .iterator();

          while (stMapIt.hasNext()) {

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

            MessageContext msgToInvoke = SandeshaUtil
                .getStoredMessageContext(key);

            RMMsgContext rmMsg = MsgInitializer
                .initializeMessage(msgToInvoke);
            Sequence seq = (Sequence) rmMsg
                .getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);
            long msgNo = seq.getMessageNumber().getMessageNumber();

            try {
              //Invoking the message.
              new AxisEngine(msgToInvoke.getConfigurationContext())
                  .receive(msgToInvoke);

              ServiceContext serviceContext = msgToInvoke
                  .getServiceContext();
              Object debug = null;
              if (serviceContext != null) {
                debug = msgToInvoke
                    .getProperty(Sandesha2ClientAPI.SANDESHA_DEBUG_MODE);
                if (debug != null && "on".equals(debug)) {
                  System.out
                      .println("DEBUG: Invoker invoking a '"
                          + SandeshaUtil
                              .getMessageTypeString(rmMsg
                                  .getMessageType())
                          + "' message.");
                }
              }

              //deleting the message entry.
              storageMapMgr.delete(key);

            } catch (AxisFault e) {
              throw new SandeshaException(e.getMessage());
            }

            //undating the next mst to invoke
            nextMsgno++;
            stMapIt = storageMapMgr
                .find(
                    new InvokerBean(null, nextMsgno,
                        sequenceId)).iterator();

            //terminate (AfterInvocation)
View Full Code Here

        StorageManager storageManager = SandeshaUtil
            .getSandeshaStorageManager(context, context
                .getAxisConfiguration());
        RMDBeanMgr rmdBeanMgr = storageManager.getRMDBeanMgr();

        InvokerBeanMgr invokerBeanMgr = storageManager
            .getInvokerBeanMgr();

        SequencePropertyBeanMgr sequencePropMgr = storageManager
            .getSequencePropertyBeanMgr();

        transaction = storageManager.getTransaction();

        // Getting the incomingSequenceIdList
        SequencePropertyBean allSequencesBean = sequencePropMgr
            .retrieve(
                Sandesha2Constants.SequenceProperties.ALL_SEQUENCES,
                Sandesha2Constants.SequenceProperties.INCOMING_SEQUENCE_LIST);

        if (allSequencesBean == null) {
          if (log.isDebugEnabled())
            log.debug("AllSequencesBean not found");
          continue;
        }
       
        // Pick a sequence using a round-robin approach
        ArrayList allSequencesList = SandeshaUtil
            .getArrayListFromString(allSequencesBean.getValue());
        int size = allSequencesList.size();
        if(nextIndex >= size) {
          nextIndex = 0;
          if (size == 0) continue;
        }
        String sequenceId = (String) allSequencesList.get(nextIndex++);
       

        RMDBean rmdBean = rmdBeanMgr.retrieve(sequenceId);
        if (rmdBean == null) {
          String message = "Next message not set correctly. Removing invalid entry.";
          log.debug(message);
 
          allSequencesList.remove(size);
         
          // cleaning the invalid data of the all sequences.
          allSequencesBean.setValue(allSequencesList.toString());
          sequencePropMgr.update(allSequencesBean);
          continue;
        }

        long nextMsgno = rmdBean.getNextMsgNoToProcess();
        if (nextMsgno <= 0) {
          if (log.isDebugEnabled())
            log.debug("Invalid Next Message Number " + nextMsgno);
          String message = SandeshaMessageHelper.getMessage(
              SandeshaMessageKeys.invalidMsgNumber, Long
                  .toString(nextMsgno));
          throw new SandeshaException(message);
        }

        Iterator stMapIt = invokerBeanMgr.find(
            new InvokerBean(null, nextMsgno, sequenceId))
            .iterator();

       
        //TODO correct the locking mechanism to have one lock per sequence.
View Full Code Here

    MessageContext msgToInvoke = null;
   
    try {
     
      StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(configurationContext,configurationContext.getAxisConfiguration());
      InvokerBeanMgr invokerBeanMgr = storageManager.getInvokerBeanMgr();
      RMDBeanMgr rmdBeanMgr = storageManager.getRMDBeanMgr();
     
      //starting a transaction
      transaction = storageManager.getTransaction();
     
      InvokerBean invokerBean = invokerBeanMgr.retrieve(messageContextKey);
     
      String sequenceId = invokerBean.getSequenceID();
      long messageNo = invokerBean.getMsgNo();
     
      msgToInvoke = storageManager.retrieveMessageContext(messageContextKey, configurationContext);
      RMMsgContext rmMsg = MsgInitializer.initializeMessage(msgToInvoke);

      String sequencePropertyKey = SandeshaUtil.getSequencePropertyKey(rmMsg);
     
      //endint the transaction before invocation.
      transaction.commit();
       
      boolean invoked = false;
     
      try {

        // Invocation is not done within a transation. This
        // may get changed when WS-AT is available.
       
        // Invoking the message.
        msgToInvoke.setProperty(Sandesha2Constants.WITHIN_TRANSACTION,
            Sandesha2Constants.VALUE_TRUE);

        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;

        AxisEngine engine = new AxisEngine(configurationContext);
        if (postFailureInvocation) {
          makeMessageReadyForReinjection(msgToInvoke);
          if (log.isDebugEnabled())
            log.debug("Receiving message, key=" + messageContextKey + ", msgCtx="
                + msgToInvoke.getEnvelope().getHeader());
          engine.receive(msgToInvoke);
        } else {
          if (log.isDebugEnabled())
            log.debug("Resuming message, key=" + messageContextKey + ", msgCtx="
                + msgToInvoke.getEnvelope().getHeader());
          msgToInvoke.setPaused(false);
          engine.resumeReceive(msgToInvoke);
        }
       
        invoked = true;

      } catch (Exception e) {
        if (log.isErrorEnabled())
          log.error ("Exception :", e);

        handleFault(msgToInvoke, e);

        // throw new SandeshaException(e);
      }
       
      //starting a transaction for the post-invocation work.
      transaction = storageManager.getTransaction();
     
      // Service will be invoked only once. I.e. even if an
      // exception get thrown in invocation
      // the service will not be invoked again.
      invokerBeanMgr.delete(messageContextKey);

      // removing the corresponding message context as well.
      MessageContext msgCtx = storageManager.retrieveMessageContext(messageContextKey, configurationContext);
      if (msgCtx != null) {
        storageManager.removeMessageContext(messageContextKey);
View Full Code Here

    if (rmdBean == null) {
      throw new SandeshaException(SandeshaMessageHelper.getMessage(SandeshaMessageKeys.cannotFindSequence,
          sequenceId));
    }

    InvokerBeanMgr invokerBeanMgr = storageManager.getInvokerBeanMgr();

    // inorder invocation is still a global property
    boolean inOrderInvocation = SandeshaUtil.getPropertyBean(
        msgCtx.getConfigurationContext().getAxisConfiguration()).isInOrder();


    //setting properties for the messageContext
    rmMsgCtx.setProperty(Sandesha2Constants.MessageContextProperties.SEQUENCE_ID,sequenceId);
    rmMsgCtx.setProperty(Sandesha2Constants.MessageContextProperties.MESSAGE_NUMBER,new Long (msgNo));
   
    if (inOrderInvocation && !msgNoPresentInList) {

      SequencePropertyBean incomingSequenceListBean = seqPropMgr.retrieve(
          Sandesha2Constants.SequenceProperties.ALL_SEQUENCES,
          Sandesha2Constants.SequenceProperties.INCOMING_SEQUENCE_LIST);

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

        // this get inserted before
        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.update(incomingSequenceListBean);
      }

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

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

   * @param sequenceID
   * @throws SandeshaException
   */
  public static void cleanReceivingSideAfterInvocation(ConfigurationContext configContext, String sequencePropertyKey ,String sequenceId,
      StorageManager storageManager) throws SandeshaException {
    InvokerBeanMgr invokerBeanMgr = storageManager.getInvokerBeanMgr();

    // removing storageMap entries
    InvokerBean findInvokerBean = new InvokerBean();
    findInvokerBean.setSequenceID(sequenceId);
    findInvokerBean.setInvoked(true);
    Collection collection = invokerBeanMgr.find(findInvokerBean);
    Iterator iterator = collection.iterator();
    while (iterator.hasNext()) {
      InvokerBean storageMapBean = (InvokerBean) iterator.next();
      invokerBeanMgr.delete(storageMapBean.getMessageContextRefKey());

      // removing the respective message context from the message store.
      // If this is an in-only message.
      // In-out message will be deleted when a ack is retrieved for the
      // out message.
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.