Package org.apache.sandesha2.storage.beans

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


    Iterator it = coll.iterator();

    boolean validSequence = false;

    while (it.hasNext()) {
      NextMsgBean nextMsgBean = (NextMsgBean) it.next();
      String tempId = nextMsgBean.getSequenceId();
      if (tempId.equals(sequenceId)) {
        validSequence = true;
        break;
      }
    }
View Full Code Here


    seqPropMgr.insert(toBean);
    seqPropMgr.insert(replyToBean);
    seqPropMgr.insert(acksToBean);

    NextMsgBeanMgr nextMsgMgr = storageManager.getNextMsgBeanMgr();
    nextMsgMgr.insert(new NextMsgBean(sequenceId, 1)); // 1 will be the next
    // message to invoke
    //this will apply for only in-order invocations.

    return sequenceId;
  }
View Full Code Here

        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)
            if (rmMsg.getMessageType() == Sandesha2Constants.MessageTypes.APPLICATION) {
              Sequence sequence = (Sequence) rmMsg
                  .getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);
              if (sequence.getLastMessage() != null) {
                TerminateManager.terminateAfterInvocation(
                    context, sequenceId);
               
                //exit from current iteration. (since an entry was removed)
                break currentIteration;
              }
            }
          }

          nextMsgBean.setNextMsgNoToProcess(nextMsgno);
          nextMsgMgr.update(nextMsgBean);

        }
      } catch (SandeshaException e1) {
        // TODO Auto-generated catch block
View Full Code Here

    Iterator iterator = table.values().iterator();

    if (bean == null)
      return beans;

    NextMsgBean temp;
    while (iterator.hasNext()) {
      temp = (NextMsgBean) iterator.next();

      boolean equal = true;

      if (bean.getNextMsgNoToProcess() > 0
          && bean.getNextMsgNoToProcess() != temp
              .getNextMsgNoToProcess())
        equal = false;

      if (bean.getSequenceId() != null
          && !bean.getSequenceId().equals(temp.getSequenceId()))
        equal = false;

      if (equal)
        beans.add(temp);
View Full Code Here

        mgr = storageManager.getNextMsgBeanMgr();

    }

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

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

    public void testFind() {
        mgr.insert(new NextMsgBean("SeqId2", 1002));
        mgr.insert(new NextMsgBean("SeqId3", 1002));

        NextMsgBean target = new NextMsgBean();
        target.setNextMsgNoToProcess(1002);

        Iterator iterator = mgr.find(target).iterator();
        NextMsgBean tmp = (NextMsgBean) iterator.next();

        if (tmp.getSequenceId().equals("SeqId2")) {
            tmp = (NextMsgBean) iterator.next();
            tmp.getSequenceId().equals("SeqId3");
        } else {
            tmp = (NextMsgBean) iterator.next();
            tmp.getSequenceId().equals("SeqId2");
        }

    }
View Full Code Here

        }

    }

    public void testInsert() {
        NextMsgBean bean = new NextMsgBean("SeqId4", 1004);
        mgr.insert(bean);
        NextMsgBean tmp = mgr.retrieve("SeqId4");
        assertTrue(tmp.getNextMsgNoToProcess() == 1004);
    }
View Full Code Here

        assertTrue(tmp.getNextMsgNoToProcess() == 1004);
    }

    public void testRetrieve() {
        assertNull(mgr.retrieve("SeqId5"));
        mgr.insert(new NextMsgBean("SeqId5", 1005));

        NextMsgBean tmp = mgr.retrieve("SeqId5");
        assertTrue(tmp.getNextMsgNoToProcess() == 1005);
    }
View Full Code Here

        NextMsgBean tmp = mgr.retrieve("SeqId5");
        assertTrue(tmp.getNextMsgNoToProcess() == 1005);
    }

    public void testUpdate() {
        NextMsgBean bean = new NextMsgBean("SeqId6", 1006);
        mgr.insert(bean);
        bean.setNextMsgNoToProcess(1007);
        mgr.update(bean);
        NextMsgBean tmp = mgr.retrieve("SeqId6");
        assertTrue(tmp.getNextMsgNoToProcess() ==1007);
    }
View Full Code Here

      StorageManager storageManager =
        SandeshaUtil.getSandeshaStorageManager(serverConfigContext, serverConfigContext.getAxisConfiguration());
     
      Transaction tran = storageManager.getTransaction();
     
      RMDBean finderBean = new RMDBean();
      List rmdBeans = storageManager.getRMDBeanMgr().find(finderBean);
     
      tran.commit();
     
      lastError = null;
     
      if (rmdBeans.isEmpty())
        lastError = new Error("rmdBeans empty " + rmdBeans);
      else {
        RMDBean bean = (RMDBean)rmdBeans.get(0);
        if (bean.isTerminated())
          break;
       
        lastError = new Error("RMDBean not deleted " + bean);
      }
    }

    if(lastError != null) throw lastError;

    while(System.currentTimeMillis() < limit) {
      Thread.sleep(tickTime); // Try the assertions each tick interval, until they pass or we time out
     
      // Check that the sequence has been deleted.
      StorageManager storageManager =
        SandeshaUtil.getSandeshaStorageManager(serverConfigContext, serverConfigContext.getAxisConfiguration());
     
      Transaction tran = storageManager.getTransaction();
     
      RMDBean finderBean = new RMDBean();
      List rmdBeans = storageManager.getRMDBeanMgr().find(finderBean);
     
      tran.commit();
     
      lastError = null;
View Full Code Here

TOP

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

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.