Examples of InvokerBean


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

  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

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

      //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

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<InvokerBean> 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

      lastMessageInvoked = invokeMessage(null);

      // Look for the next message, so long as we are still processing normally
      while(!ignoreNextMsg && lastMessageInvoked) {
        if(log.isDebugEnabled()) log.debug("InvokerWorker:: looking for next msg to invoke");
        InvokerBean finder = new InvokerBean();
        finder.setSequenceID(sequence);
        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);
            final Transaction theTran = tran;
            Runnable work = new Runnable() {
              public void run() {
                lastMessageInvoked = invokeMessage(theTran);
              }
            };

            // Wrap the work with the correct context, if needed.
            ContextManager contextMgr = SandeshaUtil.getContextManager(configurationContext);
            if(contextMgr != null) {
              work = contextMgr.wrapWithContext(work, nextBean.getContext());
            }

            // Finally do the work
            work.run();

            tran = null;
          } else {
            if(log.isDebugEnabled()) log.debug("InvokerWorker:: not pooled thread");
            nextWorker = new InvokerWorker(configurationContext, nextBean);
            nextWorker.setPooled();
            nextWorker.setWorkId(workId);

            // Wrap the invoker worker with the correct context, if needed.
            ContextManager contextMgr = SandeshaUtil.getContextManager(configurationContext);
            if(contextMgr != null) {
              nextRunnable = contextMgr.wrapWithContext(nextWorker, nextBean.getContext());
            } else {
              nextRunnable = nextWorker;
            }
          }
        }
View Full Code Here

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

        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 {

        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;

        InvocationResponse response = null;
        if (postFailureInvocation) {
          makeMessageReadyForReinjection(msgToInvoke);
          if (log.isDebugEnabled())
            log.debug("Receiving message, key=" + messageContextKey + ", msgCtx="
                + msgToInvoke.getEnvelope().getHeader());
          response = AxisEngine.receive(msgToInvoke);
        } else {
          if (log.isDebugEnabled())
            log.debug("Resuming message, key=" + messageContextKey + ", msgCtx="
                + msgToInvoke.getEnvelope().getHeader());
          msgToInvoke.setPaused(false);
          response = AxisEngine.resumeReceive(msgToInvoke);
        }

        if(!InvocationResponse.SUSPEND.equals(response)) {
          // Performance work - need to close the XMLStreamReader to prevent GC thrashing.
          SOAPEnvelope env = msgToInvoke.getEnvelope();
          if(env!=null){
            StAXBuilder sb = (StAXBuilder)msgToInvoke.getEnvelope().getBuilder();
            if(sb!=null){
              sb.close();
            }
          }
        }

        if (transaction != null && transaction.isActive()) {
          transaction.commit();
          transaction = storageManager.getTransaction();
        }

        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::invokeMessage Last message return " + messageInvoked);         
          return messageInvoked;
        }
View Full Code Here

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

    // then we should hand the message over to the invoker thread. If not, we can invoke
    // it directly ourselves.
    InvokerWorker worker = null;
    if (SandeshaUtil.isInOrder(msgCtx)) {
      String key = SandeshaUtil.getUUID(); // key to store the message.
      InvokerBean invokerBean = new InvokerBean(key, msgNo, sequenceId);
      ContextManager contextMgr = SandeshaUtil.getContextManager(configCtx);

      if(contextMgr != null) invokerBean.setContext(contextMgr.storeContext());

      boolean wasAdded = storageManager.getInvokerBeanMgr().insert(invokerBean);

      // This will avoid performing application processing more than once.
      rmMsgCtx.setProperty(Sandesha2Constants.APPLICATION_PROCESSING_DONE, "true");
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.