Package org.apache.sandesha2.storage.beans

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


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

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


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

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

    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

        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

        }
    }

    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

        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

        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

                  .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.
       
        if (stMapIt.hasNext()) { //the next Msg entry is present.

          String workId = sequenceId + "::" + nextMsgno; //creating a workId to uniquely identify the
                                   //piece of work that will be assigned to the Worker.
                   
          //check weather the bean is already assigned to a worker.
          if (lock.isWorkPresent(workId)) {
            String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.workAlreadyAssigned, workId);
            log.debug(message);
            continue;
          }
         
          InvokerBean bean = (InvokerBean) stMapIt.next();
          String messageContextKey = bean.getMessageContextRefKey();
         
          transaction.commit();

          // start a new worker thread and let it do the invocation.
          InvokerWorker worker = new InvokerWorker(context,messageContextKey);
View Full Code Here

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

      // updating the next msg to invoke

      String s = invokerBean.getSequenceID();
      RMDBean rmdBean = rmdBeanMgr.retrieve(sequenceId);

     
      if (rmMsg.getMessageType() == Sandesha2Constants.MessageTypes.APPLICATION) {
        Sequence sequence = (Sequence) rmMsg
View Full Code Here

      }

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

TOP

Related Classes of org.apache.sandesha2.storage.beans.InvokerBean

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.