Package org.apache.sandesha2.storage.beanmanagers

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


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


   
    String sequencePropertyKey = SandeshaUtil.getSequencePropertyKey(terminateSeqRMMsg);

    ConfigurationContext context = terminateSeqMsg.getConfigurationContext();
    StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(context,context.getAxisConfiguration());
    SequencePropertyBeanMgr sequencePropertyBeanMgr = storageManager.getSequencePropertyBeanMgr();
   
    // Check that the sender of this TerminateSequence holds the correct token
    SequencePropertyBean tokenBean = sequencePropertyBeanMgr.retrieve(sequencePropertyKey, Sandesha2Constants.SequenceProperties.SECURITY_TOKEN);
    if(tokenBean != null) {
      SecurityManager secManager = SandeshaUtil.getSecurityManager(context);
      OMElement body = terminateSeqRMMsg.getSOAPEnvelope().getBody();
      SecurityToken token = secManager.recoverSecurityToken(tokenBean.getValue());
      secManager.checkProofOfPossession(token, body, terminateSeqRMMsg.getMessageContext());
    }

    FaultManager faultManager = new FaultManager();
    SandeshaException fault = faultManager.checkForUnknownSequence(terminateSeqRMMsg, sequenceId,
        storageManager);
    if (fault != null) {
      throw fault;
    }


    SequencePropertyBean terminateReceivedBean = new SequencePropertyBean();
    terminateReceivedBean.setSequencePropertyKey(sequencePropertyKey);
    terminateReceivedBean.setName(Sandesha2Constants.SequenceProperties.TERMINATE_RECEIVED);
    terminateReceivedBean.setValue("true");

    sequencePropertyBeanMgr.insert(terminateReceivedBean);

    // add the terminate sequence response if required.
    RMMsgContext terminateSequenceResponse = null;
    if (SpecSpecificConstants.isTerminateSequenceResponseRequired(terminateSeqRMMsg.getRMSpecVersion()))
      terminateSequenceResponse = getTerminateSequenceResponse(terminateSeqRMMsg, sequencePropertyKey, sequenceId, storageManager);

    setUpHighestMsgNumbers(context, storageManager,sequencePropertyKey, sequenceId, terminateSeqRMMsg);

    TerminateManager.cleanReceivingSideOnTerminateMessage(context, sequencePropertyKey, sequenceId, storageManager);

    SequencePropertyBean terminatedBean = new SequencePropertyBean(sequencePropertyKey,
        Sandesha2Constants.SequenceProperties.SEQUENCE_TERMINATED, Sandesha2Constants.VALUE_TRUE);

    sequencePropertyBeanMgr.insert(terminatedBean);

    SequenceManager.updateLastActivatedTime(sequencePropertyKey, storageManager);

    //sending the terminate sequence response
    if (terminateSequenceResponse != null) {
View Full Code Here

      String requestSidesequencePropertyKey, String sequenceId, RMMsgContext terminateRMMsg) throws SandeshaException {

    if (log.isDebugEnabled())
      log.debug("Enter: TerminateSeqMsgProcessor::setUpHighestMsgNumbers, " + sequenceId);

    SequencePropertyBeanMgr seqPropMgr = storageManager.getSequencePropertyBeanMgr();

    String highestImMsgNumberStr = SandeshaUtil.getSequenceProperty(requestSidesequencePropertyKey,
        Sandesha2Constants.SequenceProperties.HIGHEST_IN_MSG_NUMBER, storageManager);
    String highestImMsgKey = SandeshaUtil.getSequenceProperty(requestSidesequencePropertyKey,
        Sandesha2Constants.SequenceProperties.HIGHEST_IN_MSG_KEY, storageManager);

    long highestInMsgNo = 0;
    if (highestImMsgNumberStr != null) {
      if (highestImMsgKey == null)
        throw new SandeshaException(SandeshaMessageHelper.getMessage(
            SandeshaMessageKeys.highestMsgKeyNotStored, sequenceId));

      highestInMsgNo = Long.parseLong(highestImMsgNumberStr);
    }

    // following will be valid only for the server side, since the obtained
    // int. seq ID is only valid there.
    String responseSideInternalSequenceId = SandeshaUtil.getOutgoingSideInternalSequenceID(sequenceId);
   
    //sequencePropertyKey is equal to the internalSequenceId for the outgoing sequence.
    String responseSideSequencePropertyKey = responseSideInternalSequenceId;
   
    long highestOutMsgNo = 0;
    try {
      boolean addResponseSideTerminate = false;
      if (highestInMsgNo == 0) {
        addResponseSideTerminate = false;
      } else {

        // setting the last in message property
        SequencePropertyBean lastInMsgBean = new SequencePropertyBean(requestSidesequencePropertyKey,
            Sandesha2Constants.SequenceProperties.LAST_IN_MESSAGE_NO, highestImMsgNumberStr);
        seqPropMgr.insert(lastInMsgBean);

        MessageContext highestInMsg = storageManager.retrieveMessageContext(highestImMsgKey, configCtx);

        // TODO get the out message in a storage friendly manner.
        MessageContext highestOutMessage = highestInMsg.getOperationContext().getMessageContext(
            OperationContextFactory.MESSAGE_LABEL_FAULT_VALUE);

        if (highestOutMessage == null || highestOutMessage.getEnvelope() == null)
          highestOutMessage = highestInMsg.getOperationContext().getMessageContext(
              OperationContextFactory.MESSAGE_LABEL_OUT_VALUE);

        if (highestOutMessage != null) {
          if (highestOutMessage.getEnvelope() == null)
            throw new SandeshaException(SandeshaMessageHelper
                .getMessage(SandeshaMessageKeys.outMsgHasNoEnvelope));

          RMMsgContext highestOutRMMsg = MsgInitializer.initializeMessage(highestOutMessage);
          Sequence seqPartOfOutMsg = (Sequence) highestOutRMMsg
              .getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);

          if (seqPartOfOutMsg != null) {

            // response message of the last in message can be
            // considered as the last out message.
            highestOutMsgNo = seqPartOfOutMsg.getMessageNumber().getMessageNumber();
            SequencePropertyBean highestOutMsgBean = new SequencePropertyBean(
                responseSideSequencePropertyKey ,
                Sandesha2Constants.SequenceProperties.LAST_OUT_MESSAGE_NO, new Long(highestOutMsgNo)
                    .toString());

            seqPropMgr.insert(highestOutMsgBean);
            addResponseSideTerminate = true;
          }
        }
      }
View Full Code Here

    Options options = msgContext.getOptions();

    StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(configurationContext,
        configurationContext.getAxisConfiguration());

    SequencePropertyBeanMgr seqPropMgr = storageManager.getSequencePropertyBeanMgr();

    String toAddress = rmMsgCtx.getTo().getAddress();
    String sequenceKey = (String) options.getProperty(SandeshaClientConstants.SEQUENCE_KEY);
    String internalSeqenceID = SandeshaUtil.getInternalSequenceID(toAddress, sequenceKey);

    String outSequenceID = SandeshaUtil.getSequenceProperty(internalSeqenceID,
        Sandesha2Constants.SequenceProperties.OUT_SEQUENCE_ID, storageManager);
    if (outSequenceID == null)
      throw new SandeshaException(SandeshaMessageHelper.getMessage(
          SandeshaMessageKeys.couldNotSendTerminateSeqNotFound, internalSeqenceID));

    // / Transaction addTerminateSeqTransaction =
    // storageManager.getTransaction();

    String terminated = SandeshaUtil.getSequenceProperty(outSequenceID,
        Sandesha2Constants.SequenceProperties.TERMINATE_ADDED, storageManager);

    // registring an InOutOperationContext for this.
    // since the serviceContext.fireAndForget only sets a inOnly One
    // this does not work when there is a terminateSequnceResponse
    // TODO do processing of terminateMessagesCorrectly., create a new
    // message instead of sendign the one given by the serviceClient
    // TODO important

    AxisOperation outInAxisOp = new OutInAxisOperation(new QName("temp"));

    AxisOperation referenceInOutOperation = msgContext.getAxisService()
        .getOperation(
            new QName(Sandesha2Constants.RM_IN_OUT_OPERATION_NAME));
    if (referenceInOutOperation == null) {
      String messge = "Cant find the recerence RM InOut operation";
      throw new SandeshaException(messge);
    }

    outInAxisOp.setParent(msgContext.getAxisService());
    // setting flows
    // outInAxisOp.setRemainingPhasesInFlow(referenceInOutOperation.getRemainingPhasesInFlow());
    outInAxisOp.setRemainingPhasesInFlow(referenceInOutOperation
        .getRemainingPhasesInFlow());
    outInAxisOp.setMessageReceiver(new RMMessageReceiver ());
   
    OperationContext opcontext = OperationContextFactory
        .createOperationContext(
            WSDL20_2004Constants.MEP_CONSTANT_OUT_IN, outInAxisOp);
    opcontext.setParent(msgContext.getServiceContext());
    configurationContext.registerOperationContext(rmMsgCtx.getMessageId(),
        opcontext);

    msgContext.setOperationContext(opcontext);
    msgContext.setAxisOperation(outInAxisOp);
   
    if (terminated != null && "true".equals(terminated)) {
      String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.terminateAddedPreviously);
      log.debug(message);
      return false;
    }

    TerminateSequence terminateSequencePart = (TerminateSequence) rmMsgCtx
        .getMessagePart(Sandesha2Constants.MessageParts.TERMINATE_SEQ);
    terminateSequencePart.getIdentifier().setIndentifer(outSequenceID);

    rmMsgCtx.setFlow(MessageContext.OUT_FLOW);
    msgContext.setProperty(Sandesha2Constants.APPLICATION_PROCESSING_DONE, "true");

    rmMsgCtx.setTo(new EndpointReference(toAddress));

    String rmVersion = SandeshaUtil.getRMVersion(internalSeqenceID, storageManager);
    if (rmVersion == null)
      throw new SandeshaException(SandeshaMessageHelper.getMessage(SandeshaMessageKeys.cannotDecideRMVersion));

    rmMsgCtx.setWSAAction(SpecSpecificConstants.getTerminateSequenceAction(rmVersion));
    rmMsgCtx.setSOAPAction(SpecSpecificConstants.getTerminateSequenceSOAPAction(rmVersion));

    String transportTo = SandeshaUtil.getSequenceProperty(internalSeqenceID,
        Sandesha2Constants.SequenceProperties.TRANSPORT_TO, storageManager);
    if (transportTo != null) {
      rmMsgCtx.setProperty(MessageContextConstants.TRANSPORT_URL, transportTo);
    }
   
   
    //setting msg context properties
    rmMsgCtx.setProperty(Sandesha2Constants.MessageContextProperties.SEQUENCE_ID, outSequenceID);
    rmMsgCtx.setProperty(Sandesha2Constants.MessageContextProperties.INTERNAL_SEQUENCE_ID, internalSeqenceID);
    rmMsgCtx.setProperty(Sandesha2Constants.MessageContextProperties.SEQUENCE_PROPERTY_KEY , sequenceKey);

    try {
      rmMsgCtx.addSOAPEnvelope();
    } catch (AxisFault e) {
      throw new SandeshaException(e.getMessage(),e);
    }

    String key = SandeshaUtil.getUUID();

    SenderBean terminateBean = new SenderBean();
    terminateBean.setMessageContextRefKey(key);

    storageManager.storeMessageContext(key, msgContext);

    // Set a retransmitter lastSentTime so that terminate will be send with
    // some delay.
    // Otherwise this get send before return of the current request (ack).
    // TODO: refine the terminate delay.
    terminateBean.setTimeToSend(System.currentTimeMillis() + Sandesha2Constants.TERMINATE_DELAY);

    terminateBean.setMessageID(msgContext.getMessageID());
   
    EndpointReference to = msgContext.getTo();
    if (to!=null)
      terminateBean.setToAddress(to.getAddress());
   
    // this will be set to true at the sender.
    terminateBean.setSend(true);

    msgContext.setProperty(Sandesha2Constants.QUALIFIED_FOR_SENDING, Sandesha2Constants.VALUE_FALSE);

    terminateBean.setReSend(false);

    SenderBeanMgr senderBeanMgr = storageManager.getSenderBeanMgr();

    senderBeanMgr.insert(terminateBean);

    SequencePropertyBean terminateAdded = new SequencePropertyBean();
    terminateAdded.setName(Sandesha2Constants.SequenceProperties.TERMINATE_ADDED);
    terminateAdded.setSequencePropertyKey(outSequenceID);
    terminateAdded.setValue("true");

    seqPropMgr.insert(terminateAdded);

    rmMsgCtx.setProperty(Sandesha2Constants.SET_SEND_TO_TRUE, Sandesha2Constants.VALUE_TRUE);

    SandeshaUtil.executeAndStore(rmMsgCtx, key);
View Full Code Here

      long msgNo = sequence.getMessageNumber().getMessageNumber();
     
      String propertyKey = SandeshaUtil.getSequencePropertyKey(rmMsgContext);

      if (propertyKey != null && msgNo > 0) {
        SequencePropertyBeanMgr seqPropMgr = storageManager.getSequencePropertyBeanMgr();
        SequencePropertyBean receivedMsgsBean = seqPropMgr.retrieve(propertyKey,
            Sandesha2Constants.SequenceProperties.SERVER_COMPLETED_MESSAGES);
        if (receivedMsgsBean != null) {
          String receivedMsgStr = receivedMsgsBean.getValue();
          ArrayList msgNoArrList = SandeshaUtil.getSplittedMsgNoArraylist(receivedMsgStr);

          Iterator iterator = msgNoArrList.iterator();
          while (iterator.hasNext()) {
            String temp = (String) iterator.next();
            String msgNoStr = new Long(msgNo).toString();
            if (msgNoStr.equals(temp)) {
              drop = true;
            }
          }
        }

        if (drop == false) {
          // Checking for RM specific EMPTY_BODY LASTMESSAGE.
          SOAPBody body = rmMsgContext.getSOAPEnvelope().getBody();
          boolean emptyBody = false;
          if (body.getChildElements().hasNext() == false) {
            emptyBody = true;
          }

          if (emptyBody) {
            if (sequence.getLastMessage() != null) {
              log.debug(SandeshaMessageHelper.getMessage(SandeshaMessageKeys.emptyLastMsg));
              drop = true;

              if (receivedMsgsBean == null) {
                receivedMsgsBean = new SequencePropertyBean(sequenceId,
                    Sandesha2Constants.SequenceProperties.SERVER_COMPLETED_MESSAGES, "");
                seqPropMgr.insert(receivedMsgsBean);
              }

              String receivedMsgStr = receivedMsgsBean.getValue();
              if (!receivedMsgStr.equals("") && receivedMsgStr != null)
                receivedMsgStr = receivedMsgStr + "," + Long.toString(msgNo);
              else
                receivedMsgStr = Long.toString(msgNo);

              receivedMsgsBean.setValue(receivedMsgStr);

              // TODO correct the syntac into '[received msgs]'

              seqPropMgr.update(receivedMsgsBean);

              ApplicationMsgProcessor ackProcessor = new ApplicationMsgProcessor();
              ackProcessor.sendAckIfNeeded(rmMsgContext, receivedMsgStr, storageManager);
             
             
View Full Code Here

      if (sequence != null) {
        sequenceId = sequence.getIdentifier().getIdentifier();
      }

      SequencePropertyBeanMgr seqPropMgr = storageManager.getSequencePropertyBeanMgr();
      SequencePropertyBean receivedMsgsBean = seqPropMgr.retrieve(sequenceId,
          Sandesha2Constants.SequenceProperties.SERVER_COMPLETED_MESSAGES);
      String receivedMsgStr = receivedMsgsBean.getValue();

      ApplicationMsgProcessor ackProcessor = new ApplicationMsgProcessor();
      // Even though the duplicate message is dropped, hv to send the ack
View Full Code Here

    Sequence sequence = (Sequence) applicationRMMessage.getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);
    long messageNumber = sequence.getMessageNumber().getMessageNumber();
    String sequenceID = sequence.getIdentifier().getIdentifier();

    ConfigurationContext configCtx = applicationRMMessage.getMessageContext().getConfigurationContext();
    SequencePropertyBeanMgr seqPropMgr = storageManager.getSequencePropertyBeanMgr();

    boolean lastMessageNumberExceeded = false;
    String reason = null;
    SequencePropertyBean lastMessageBean = seqPropMgr.retrieve(sequenceID,
        Sandesha2Constants.SequenceProperties.LAST_OUT_MESSAGE_NO);
    if (lastMessageBean != null) {
      long lastMessageNo = Long.parseLong(lastMessageBean.getValue());
      if (messageNumber > lastMessageNo) {
        lastMessageNumberExceeded = true;
View Full Code Here

      log.debug("Enter: FaultManager::checkForSequenceClosed, " + sequenceID);

    MessageContext referenceMessage = referenceRMMessage.getMessageContext();
    ConfigurationContext configCtx = referenceMessage.getConfigurationContext();

    SequencePropertyBeanMgr seqPropMgr = storageManager.getSequencePropertyBeanMgr();

    boolean sequenceClosed = false;
    String reason = null;
    SequencePropertyBean sequenceClosedBean = seqPropMgr.retrieve(sequenceID,
        Sandesha2Constants.SequenceProperties.SEQUENCE_CLOSED);
    if (sequenceClosedBean != null && Sandesha2Constants.VALUE_TRUE.equals(sequenceClosedBean.getValue())) {
      sequenceClosed = true;
      reason = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.cannotAcceptMsgAsSequenceClosed, sequenceID);
    }
View Full Code Here

   
    MessageContext msgContext = terminateResRMMsg.getMessageContext();
    ConfigurationContext context = terminateResRMMsg.getConfigurationContext();
   
    StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(context,context.getAxisConfiguration());
    SequencePropertyBeanMgr sequencePropertyBeanMgr = storageManager.getSequencePropertyBeanMgr();
   
    TerminateSequenceResponse tsResponse = (TerminateSequenceResponse)
      terminateResRMMsg.getMessagePart(Sandesha2Constants.MessageParts.TERMINATE_SEQ_RESPONSE);
   
    String sequenceId = tsResponse.getIdentifier().getIdentifier();
    String internalSequenceID = SandeshaUtil.getSequenceProperty(sequenceId,
        Sandesha2Constants.SequenceProperties.INTERNAL_SEQUENCE_ID, storageManager);
    msgContext.setProperty(Sandesha2Constants.MessageContextProperties.INTERNAL_SEQUENCE_ID,internalSequenceID);
    String sequencePropertyKey = SandeshaUtil.getSequencePropertyKey(terminateResRMMsg);

    // Check that the sender of this TerminateSequence holds the correct token
    SequencePropertyBean tokenBean = sequencePropertyBeanMgr.retrieve(sequencePropertyKey, Sandesha2Constants.SequenceProperties.SECURITY_TOKEN);
    if(tokenBean != null) {
      SecurityManager secManager = SandeshaUtil.getSecurityManager(context);
      OMElement body = terminateResRMMsg.getSOAPEnvelope().getBody();
      SecurityToken token = secManager.recoverSecurityToken(tokenBean.getValue());
      secManager.checkProofOfPossession(token, body, msgContext);
View Full Code Here

    SequenceReport sequenceReport = new SequenceReport();
    sequenceReport.setSequenceDirection(SequenceReport.SEQUENCE_DIRECTION_OUT);

    StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(configurationContext,configurationContext.getAxisConfiguration());
    SequencePropertyBeanMgr seqPropMgr = storageManager.getSequencePropertyBeanMgr();
    RMSBeanMgr rmsBeanMgr = storageManager.getRMSBeanMgr();

    String withinTransactionStr = (String) configurationContext.getProperty(Sandesha2Constants.WITHIN_TRANSACTION);
    boolean withinTransaction = false;
    if (withinTransactionStr != null && Sandesha2Constants.VALUE_TRUE.equals(withinTransactionStr))
View Full Code Here

TOP

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

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.