Package org.apache.sandesha2.storage.beans

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


        }
    }

    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

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

    public void testDelete() throws SandeshaStorageException{
        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() throws SandeshaStorageException {
        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() throws SandeshaStorageException {
        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() throws SandeshaStorageException {
        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() throws SandeshaStorageException {
        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

    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

          String sequenceId = (String) allSequencesItr.next();
         
          Transaction invocationTransaction = storageManager.getTransaction();   //Transaction based invocation
         
          NextMsgBean nextMsgBean = nextMsgMgr.retrieve(sequenceId);
          if (nextMsgBean == null) {

            String message = "Next message not set correctly. Removing invalid entry.";
            log.debug(message);
            allSequencesItr.remove();
           
            //cleaning the invalid data of the all sequences.
            allSequencesBean.setValue(allSequencesList.toString());
            sequencePropMgr.update(allSequencesBean)
           
            throw new SandeshaException (message);
          }

          long nextMsgno = nextMsgBean.getNextMsgNoToProcess();
          if (nextMsgno <= 0) {
            String message = "Invalid messaage number as the Next Message Number. Removing invalid entry";
           
            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
                .initializeMessage(msgToInvoke);
            Sequence seq = (Sequence) rmMsg
                .getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);

            long msgNo = seq.getMessageNumber().getMessageNumber();

            try {
              //Invoking the message.

              //currently Transaction based invocation can be supplied only for the in-only case.
             
              if (!AxisOperationFactory.MEP_URI_IN_ONLY.equals(msgToInvoke.getAxisOperation().getMessageExchangePattern())) {
                invocationTransaction.commit();
              }
             
              new AxisEngine (msgToInvoke.getConfigurationContext())
                  .resume(msgToInvoke);
              invoked = true;
             
              if (!AxisOperationFactory.MEP_URI_IN_ONLY.equals(msgToInvoke.getAxisOperation().getMessageExchangePattern())) {
                invocationTransaction = storageManager.getTransaction();
              }           

              storageMapMgr.delete(key);
            } catch (AxisFault e) {
              throw new SandeshaException(e);
            }

            //undating the next msg to invoke


            if (rmMsg.getMessageType() == Sandesha2Constants.MessageTypes.APPLICATION) {
              Sequence sequence = (Sequence) rmMsg
                  .getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);
              if (sequence.getLastMessage() != null) {
               
                TerminateManager.cleanReceivingSideAfterInvocation(context, sequenceId);
               
                //this sequence has no more invocations
//                stopInvokerForTheSequence(sequenceId);
               
                //exit from current iteration. (since an entry was removed)
                invocationTransaction.commit();
                break currentIteration;
              }
            }
          }

          if (invoked) {
            nextMsgno++;
            nextMsgBean.setNextMsgNoToProcess(nextMsgno);
            nextMsgMgr.update(nextMsgBean);
            invocationTransaction.commit();
          }
        }
       
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.