Examples of InvokerBeanMgr


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

        StorageManager storageManager = SandeshaUtil
            .getSandeshaStorageManager(context);
        NextMsgBeanMgr nextMsgMgr = storageManager.getNextMsgBeanMgr();

        InvokerBeanMgr storageMapMgr = storageManager
            .getStorageMapBeanMgr();

        SequencePropertyBeanMgr sequencePropMgr = storageManager
            .getSequencePropretyBeanMgr();

        //Getting the incomingSequenceIdList
        SequencePropertyBean sequencePropertyBean = (SequencePropertyBean) sequencePropMgr
            .retrieve(
                Sandesha2Constants.SequenceProperties.ALL_SEQUENCES,
                Sandesha2Constants.SequenceProperties.INCOMING_SEQUENCE_LIST);
        if (sequencePropertyBean == null)
          continue;

        ArrayList seqPropList = (ArrayList) sequencePropertyBean
            .getValue();
        Iterator seqPropIt = seqPropList.iterator();

        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)
View Full Code Here

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

        StorageManager storageManager = SandeshaUtil
            .getSandeshaStorageManager(context, context
                .getAxisConfiguration());
        RMDBeanMgr rmdBeanMgr = storageManager.getRMDBeanMgr();

        InvokerBeanMgr invokerBeanMgr = storageManager
            .getInvokerBeanMgr();

        SequencePropertyBeanMgr sequencePropMgr = storageManager
            .getSequencePropertyBeanMgr();

        transaction = storageManager.getTransaction();

        // Getting the incomingSequenceIdList
        SequencePropertyBean allSequencesBean = sequencePropMgr
            .retrieve(
                Sandesha2Constants.SequenceProperties.ALL_SEQUENCES,
                Sandesha2Constants.SequenceProperties.INCOMING_SEQUENCE_LIST);

        if (allSequencesBean == null) {
          if (log.isDebugEnabled())
            log.debug("AllSequencesBean not found");
          continue;
        }
       
        // Pick a sequence using a round-robin approach
        ArrayList allSequencesList = SandeshaUtil
            .getArrayListFromString(allSequencesBean.getValue());
        int size = allSequencesList.size();
        if(nextIndex >= size) {
          nextIndex = 0;
          if (size == 0) continue;
        }
        String sequenceId = (String) allSequencesList.get(nextIndex++);
       

        RMDBean rmdBean = rmdBeanMgr.retrieve(sequenceId);
        if (rmdBean == null) {
          String message = "Next message not set correctly. Removing invalid entry.";
          log.debug(message);
 
          allSequencesList.remove(size);
         
          // cleaning the invalid data of the all sequences.
          allSequencesBean.setValue(allSequencesList.toString());
          sequencePropMgr.update(allSequencesBean);
          continue;
        }

        long nextMsgno = rmdBean.getNextMsgNoToProcess();
        if (nextMsgno <= 0) {
          if (log.isDebugEnabled())
            log.debug("Invalid Next Message Number " + nextMsgno);
          String message = SandeshaMessageHelper.getMessage(
              SandeshaMessageKeys.invalidMsgNumber, Long
                  .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.
View Full Code Here

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

    MessageContext msgToInvoke = null;
   
    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);
View Full Code Here

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

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

    InvokerBeanMgr invokerBeanMgr = storageManager.getInvokerBeanMgr();

    // inorder invocation is still a global property
    boolean inOrderInvocation = SandeshaUtil.getPropertyBean(
        msgCtx.getConfigurationContext().getAxisConfiguration()).isInOrder();


    //setting properties for the messageContext
    rmMsgCtx.setProperty(Sandesha2Constants.MessageContextProperties.SEQUENCE_ID,sequenceId);
    rmMsgCtx.setProperty(Sandesha2Constants.MessageContextProperties.MESSAGE_NUMBER,new Long (msgNo));
   
    if (inOrderInvocation && !msgNoPresentInList) {

      SequencePropertyBean incomingSequenceListBean = seqPropMgr.retrieve(
          Sandesha2Constants.SequenceProperties.ALL_SEQUENCES,
          Sandesha2Constants.SequenceProperties.INCOMING_SEQUENCE_LIST);

      if (incomingSequenceListBean == null) {
        ArrayList incomingSequenceList = new ArrayList();
        incomingSequenceListBean = new SequencePropertyBean();
        incomingSequenceListBean.setSequencePropertyKey(Sandesha2Constants.SequenceProperties.ALL_SEQUENCES);
        incomingSequenceListBean.setName(Sandesha2Constants.SequenceProperties.INCOMING_SEQUENCE_LIST);
        incomingSequenceListBean.setValue(incomingSequenceList.toString());

        // this get inserted before
        seqPropMgr.insert(incomingSequenceListBean);
      }

      ArrayList incomingSequenceList = SandeshaUtil.getArrayListFromString(incomingSequenceListBean.getValue());

      // Adding current sequence to the incoming sequence List.
      if (!incomingSequenceList.contains(sequenceId)) {
        incomingSequenceList.add(sequenceId);

        // saving the property.
        incomingSequenceListBean.setValue(incomingSequenceList.toString());
        seqPropMgr.update(incomingSequenceListBean);
      }

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

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

   * @param sequenceID
   * @throws SandeshaException
   */
  public static void cleanReceivingSideAfterInvocation(ConfigurationContext configContext, String sequencePropertyKey ,String sequenceId,
      StorageManager storageManager) throws SandeshaException {
    InvokerBeanMgr invokerBeanMgr = storageManager.getInvokerBeanMgr();

    // removing storageMap entries
    InvokerBean findInvokerBean = new InvokerBean();
    findInvokerBean.setSequenceID(sequenceId);
    findInvokerBean.setInvoked(true);
    Collection collection = invokerBeanMgr.find(findInvokerBean);
    Iterator iterator = collection.iterator();
    while (iterator.hasNext()) {
      InvokerBean storageMapBean = (InvokerBean) iterator.next();
      invokerBeanMgr.delete(storageMapBean.getMessageContextRefKey());

      // removing the respective message context from the message store.
      // If this is an in-only message.
      // In-out message will be deleted when a ack is retrieved for the
      // out message.
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.