Package org.apache.sandesha2.storage.beanmanagers

Examples of org.apache.sandesha2.storage.beanmanagers.RMDBeanMgr


   
    try {
     
      StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(configurationContext,configurationContext.getAxisConfiguration());
      InvokerBeanMgr invokerBeanMgr = storageManager.getInvokerBeanMgr();
      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
            .getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);
       
        //TODO support WSRM 1.1 spce here ( there is no last message concept)
        if (sequence.getLastMessage() != null) {
          TerminateManager.cleanReceivingSideAfterInvocation(configurationContext, sequencePropertyKey, sequenceId, storageManager);
          // exit from current iteration. (since an entry
          // was removed)
         
          return;
        }
      }
     
      long nextMsgNo = rmdBean.getNextMsgNoToProcess();
     
      if (!(messageNo==nextMsgNo)) {
        String message = "Operated message number is different from the Next Message Number to invoke";
        throw new SandeshaException (message);
      }
     
      if (invoked) {
        nextMsgNo++;
        rmdBean.setNextMsgNoToProcess(nextMsgNo);
        rmdBeanMgr.update(rmdBean);
      }
    } catch (SandeshaStorageException e) {
      transaction.rollback();
    } catch (SandeshaException e) {
      if (log.isErrorEnabled())
View Full Code Here


   
    while (isPoll()) {
     
      try {
       
        RMDBeanMgr rmdBeanMgr = storageManager.getRMDBeanMgr();
       
        //geting the sequences to be polled.
        //if shedule contains any requests, do the earliest one.
        //else pick one randomly.
       
        String sequenceId = getNextSheduleEntry ();

        RMDBean rmdBean = null;
       
        if (sequenceId==null) {
         
          RMDBean findBean = new RMDBean ();
          findBean.setPollingMode(true);
         
          List results = rmdBeanMgr.find(findBean);
          int size = results.size();
          if (size>0) {
            Random random = new Random ();
            int item = random.nextInt(size);
            rmdBean = (RMDBean) results.get(item);
          }
         
         
         
        } else {
          RMDBean findBean = new RMDBean ();
          findBean.setPollingMode(true);
          findBean.setSequenceID(sequenceId);
         
          rmdBean = rmdBeanMgr.findUnique(findBean);
        }
       
        //If not valid entry is found, try again later.
        if (rmdBean==null)
          continue;
View Full Code Here

    if (!coll.isEmpty()) {
      validSequence = true;

    } else {
      // Look for an inbound sequence
      RMDBeanMgr rmdBeanMgr = storageManager.getRMDBeanMgr();

      coll = rmdBeanMgr.retrieveAll();
      Iterator it = coll.iterator();

      while (it.hasNext()) {
        RMDBean rmdBean = (RMDBean) it.next();
        String tempId = rmdBean.getSequenceID();
View Full Code Here

    //shedulling a polling request for the response side.
    String offeredSequenceId = SandeshaUtil.getSequenceProperty(sequencePropertyKey,
        Sandesha2Constants.SequenceProperties.OFFERED_SEQUENCE, storageManager);
   
    if (offeredSequenceId!=null) {
      RMDBeanMgr rmdBeanMgr = storageManager.getRMDBeanMgr();
      RMDBean rmdBean = rmdBeanMgr.retrieve(sequenceId);
     
      if (rmdBean!=null && rmdBean.isPollingMode())
        SandeshaUtil.shedulePollingRequest(offeredSequenceId, configContext);
    }
View Full Code Here

        Sandesha2Constants.SequenceProperties.SEQUENCE_TIMED_OUT);
    if (timedOutBean != null) {
      return SequenceReport.SEQUENCE_STATUS_TIMED_OUT;
    }

    RMDBeanMgr rmdBeanMgr = storageManager.getRMDBeanMgr();
    RMDBean rmdBean = rmdBeanMgr.retrieve(sequenceID);

    if (rmdBean != null) {
      return SequenceReport.SEQUENCE_STATUS_ESTABLISHED;
    }
View Full Code Here

      msgsBean.setValue(messagesStr);
      seqPropMgr.update(msgsBean);
    }

    // Pause the messages bean if not the right message to invoke.
    RMDBeanMgr rmdBeanMgr = storageManager.getRMDBeanMgr();
    RMDBean rmdBean = rmdBeanMgr.retrieve(sequenceId);

    if (rmdBean == null) {
      throw new SandeshaException(SandeshaMessageHelper.getMessage(SandeshaMessageKeys.cannotFindSequence,
          sequenceId));
    }
View Full Code Here

   * methods.
   *
   */
  private static void completeTerminationOfReceivingSide(ConfigurationContext configContext, String sequencePropertyKey,String sequenceId,
      StorageManager storageManager) throws SandeshaException {
    RMDBeanMgr rmdBeanMgr = storageManager.getRMDBeanMgr();

    // removing nextMsgMgr entries
    RMDBean findRMDBean = new RMDBean();
    findRMDBean.setSequenceID(sequenceId);
    Collection collection = rmdBeanMgr.find(findRMDBean);
    Iterator iterator = collection.iterator();
    while (iterator.hasNext()) {
      RMDBean nextMsgBean = (RMDBean) iterator.next();
       rmdBeanMgr.delete(nextMsgBean.getSequenceID());
    }

    // removing the HighestInMessage entry.
    String highestInMessageKey = SandeshaUtil.getSequenceProperty(sequencePropertyKey,
        Sandesha2Constants.SequenceProperties.HIGHEST_IN_MSG_KEY, storageManager);
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

    RMDBeanMgr rmdBeanMgr = storageManager.getRMDBeanMgr();
   
    String seqID = SandeshaUtil.getUUID();
   
    // Mockup an RMDBean
    RMDBean rmdBean = new RMDBean();
    rmdBean.setSequenceID(seqID);
    rmdBean.setToEPR(AddressingConstants.Final.WSA_ANONYMOUS_URL);
    rmdBean.setAcksToEPR(AddressingConstants.Final.WSA_ANONYMOUS_URL);
    rmdBean.setReplyToEPR(AddressingConstants.Final.WSA_ANONYMOUS_URL);
    rmdBean.setRMVersion(Sandesha2Constants.SPEC_VERSIONS.v1_1);
    rmdBean.setServerCompletedMessages(new RangeString());
    // Flag that the sequence is closed.
    rmdBean.setClosed(true);
   
    // Create a transaction and insert the RMSBean
    Transaction tran = storageManager.getTransaction();
   
    rmdBeanMgr.insert(rmdBean);
View Full Code Here

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

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

TOP

Related Classes of org.apache.sandesha2.storage.beanmanagers.RMDBeanMgr

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.