Examples of InvokerBean


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

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

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

        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

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

    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

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

    public void tearDown() throws Exception {
      transaction.commit();
    }

    public void testDelete() throws SandeshaStorageException {
        mgr.insert(new InvokerBean("Key1", 1001, "SeqId1"));
        mgr.delete("Key1");
        assertNull(mgr.retrieve("Key1"));
    }
View Full Code Here

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

        mgr.delete("Key1");
        assertNull(mgr.retrieve("Key1"));
    }

    public void testFind() throws SandeshaStorageException {
        mgr.insert(new InvokerBean("Key2", 1002, "SeqId2"));
        mgr.insert(new InvokerBean("Key3", 1003, "SeqId2"));

        InvokerBean bean = new InvokerBean();
        bean.setSequenceID("SeqId2");

        Iterator iter = mgr.find(bean).iterator();
        InvokerBean tmp = (InvokerBean) iter.next();

        if (tmp.getMessageContextRefKey().equals("Key2")) {
            tmp = (InvokerBean) iter.next();
            assertTrue(tmp.getMessageContextRefKey().equals("Key3"));
        } else {
            tmp = (InvokerBean) iter.next();
            assertTrue(tmp.getMessageContextRefKey().equals("Key2"));

        }
    }
View Full Code Here

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

        }
    }

    public void testInsert() throws SandeshaStorageException {
        mgr.insert(new InvokerBean("Key4", 1004, "SeqId4"));
        InvokerBean tmp = mgr.retrieve("Key4");
        assertTrue(tmp.getMessageContextRefKey().equals("Key4"));
    }
View Full Code Here

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

        assertTrue(tmp.getMessageContextRefKey().equals("Key4"));
    }

    public void testRetrieve() throws SandeshaStorageException {
        assertNull(mgr.retrieve("Key5"));
        mgr.insert(new InvokerBean("Key5", 1004, "SeqId5"));
        assertNotNull(mgr.retrieve("Key5"));
    }
View Full Code Here

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

        mgr.insert(new InvokerBean("Key5", 1004, "SeqId5"));
        assertNotNull(mgr.retrieve("Key5"));
    }

    public void testUpdate() throws SandeshaStorageException {
        InvokerBean bean = new InvokerBean("Key6", 1006, "SeqId6");
        mgr.insert(bean);
        bean.setMsgNo(1007);
        mgr.update(bean);
        InvokerBean tmp = mgr.retrieve("Key6");
        assertTrue(tmp.getMsgNo() == 1007);
    }
View Full Code Here

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

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

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

  public synchronized Collection find(InvokerBean bean) {
    ArrayList beans = new ArrayList();
    Iterator iterator = table.values().iterator();

    InvokerBean temp = new InvokerBean();
    while (iterator.hasNext()) {
      temp = (InvokerBean) iterator.next();
      boolean select = true;

      if (bean.getMessageContextRefKey() != null && !bean.getMessageContextRefKey().equals(temp.getMessageContextRefKey()))
        select = false;

      if (bean.getMsgNo() != 0 && bean.getMsgNo() != temp.getMsgNo())
        select = false;

      if (bean.getSequenceID() != null
          && !bean.getSequenceID().equals(temp.getSequenceID()))
        select = false;
     
      if (bean.isInvoked()!=temp.isInvoked())
        select = false;

      if (select)
        beans.add(temp);
    }
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.