Examples of SequencePropertyBean


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

   
    String outSequenceID = SandeshaUtil.getSequenceProperty(internalSequenceID,Sandesha2Constants.SequenceProperties.OUT_SEQUENCE_ID,configContext);
   
    if (!serverSide) {
      boolean stopListnerForAsyncAcks = false;
      SequencePropertyBean acksToBean = sequencePropertyBeanMgr.retrieve(internalSequenceID,Sandesha2Constants.SequenceProperties.ACKS_TO_EPR);
       
      String addressingNamespace = SandeshaUtil.getSequenceProperty(internalSequenceID,Sandesha2Constants.SequenceProperties.ADDRESSING_NAMESPACE_VALUE,configContext);
      String anonymousURI = SpecSpecificConstants.getAddressingAnonymousURI(addressingNamespace);
       
      if (acksToBean!=null) {
        String acksTo = acksToBean.getValue();
        if (acksTo!=null && !anonymousURI.equals(acksTo)) {
          stopListnerForAsyncAcks = true;
        }
      }
    }
   
    //removing retransmitterMgr entries
    Collection collection = retransmitterBeanMgr.find(internalSequenceID);
    Iterator iterator = collection.iterator();
    while (iterator.hasNext()) {
      SenderBean retransmitterBean = (SenderBean) iterator.next();
      retransmitterBeanMgr.delete(retransmitterBean.getMessageID());
    }
   
    //removing the createSeqMgrEntry
    CreateSeqBean findCreateSequenceBean = new CreateSeqBean ();
    findCreateSequenceBean.setInternalSequenceID(internalSequenceID);
    collection = createSeqBeanMgr.find(findCreateSequenceBean);
    iterator = collection.iterator();
    while (iterator.hasNext()) {
      CreateSeqBean createSeqBean = (CreateSeqBean) iterator.next();
      createSeqBeanMgr.delete(createSeqBean.getCreateSeqMsgID());
    }
   
    //removing sequence properties
    SequencePropertyBean findSequencePropertyBean1 = new SequencePropertyBean ();
    findSequencePropertyBean1.setSequenceID(internalSequenceID);
    collection = sequencePropertyBeanMgr.find(findSequencePropertyBean1);
    iterator = collection.iterator();
    while (iterator.hasNext()) {
      SequencePropertyBean sequencePropertyBean = (SequencePropertyBean) iterator.next();
      doUpdatesIfNeeded (outSequenceID,sequencePropertyBean,sequencePropertyBeanMgr);
     
      if (isProportyDeletable(sequencePropertyBean.getName())) {
        sequencePropertyBeanMgr.delete(sequencePropertyBean.getSequenceID(),sequencePropertyBean.getName());
      }
    }
  }
View Full Code Here

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

    Transaction addTerminateSeqTransaction = storageManager.getTransaction();
   
    SequencePropertyBeanMgr seqPropMgr = storageManager
        .getSequencePropretyBeanMgr();

    SequencePropertyBean terminated = seqPropMgr.retrieve(outSequenceId,
        Sandesha2Constants.SequenceProperties.TERMINATE_ADDED);

    if (terminated != null && terminated.getValue() != null
        && "true".equals(terminated.getValue())) {
      String message = "Terminate was added previously.";
      log.info(message);
    }

    RMMsgContext terminateRMMessage = RMMsgCreator
        .createTerminateSequenceMessage(referenceMessage, outSequenceId,internalSequenceId);
    terminateRMMessage.setFlow(MessageContext.OUT_FLOW);
    terminateRMMessage.setProperty(Sandesha2Constants.APPLICATION_PROCESSING_DONE,"true");
   
    SequencePropertyBean toBean = seqPropMgr.retrieve(internalSequenceId,
        Sandesha2Constants.SequenceProperties.TO_EPR);

    EndpointReference toEPR = new EndpointReference ( toBean.getValue());
    if (toEPR == null) {
      String message = "To EPR has an invalid value";
      throw new SandeshaException(message);
    }

    terminateRMMessage.setTo(new EndpointReference(toEPR.getAddress()));
   
    String addressingNamespaceURI = SandeshaUtil.getSequenceProperty(internalSequenceId,Sandesha2Constants.SequenceProperties.ADDRESSING_NAMESPACE_VALUE,configurationContext);
    String anonymousURI = SpecSpecificConstants.getAddressingAnonymousURI(addressingNamespaceURI);
   
    String rmVersion = SandeshaUtil.getRMVersion(internalSequenceId,configurationContext);
    if (rmVersion==null)
      throw new SandeshaException ("Cant find the rmVersion of the given message");
    terminateRMMessage.setWSAAction(SpecSpecificConstants.getTerminateSequenceAction(rmVersion));
    terminateRMMessage.setSOAPAction(SpecSpecificConstants.getTerminateSequenceSOAPAction(rmVersion));

    SequencePropertyBean transportToBean = seqPropMgr.retrieve(internalSequenceId,Sandesha2Constants.SequenceProperties.TRANSPORT_TO);
    if (transportToBean!=null) {
      terminateRMMessage.setProperty(MessageContextConstants.TRANSPORT_URL,transportToBean.getValue());
    }
   
    try {
      terminateRMMessage.addSOAPEnvelope();
    } catch (AxisFault e) {
      throw new SandeshaException(e.getMessage());
    }

    String key = SandeshaUtil.getUUID();
   
    SenderBean terminateBean = new SenderBean();
    terminateBean.setMessageContextRefKey(key);

   
    storageManager.storeMessageContext(key,terminateRMMessage.getMessageContext());

   
    //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(terminateRMMessage.getMessageId());
   
    //this will be set to true at the sender.
    terminateBean.setSend(true);
   
    terminateRMMessage.getMessageContext().setProperty(Sandesha2Constants.QUALIFIED_FOR_SENDING,
        Sandesha2Constants.VALUE_FALSE);
   
    terminateBean.setReSend(false);

    SenderBeanMgr retramsmitterMgr = storageManager
        .getRetransmitterBeanMgr();

    retramsmitterMgr.insert(terminateBean);
   
    SequencePropertyBean terminateAdded = new SequencePropertyBean();
    terminateAdded.setName(Sandesha2Constants.SequenceProperties.TERMINATE_ADDED);
    terminateAdded.setSequenceID(outSequenceId);
    terminateAdded.setValue("true");

    seqPropMgr.insert(terminateAdded);
   
    //This should be dumped to the storage by the sender
    TransportOutDescription transportOut = terminateRMMessage.getMessageContext().getTransportOut();
View Full Code Here

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

    }
  }

  public synchronized boolean delete(String sequenceId, String name) {
   
    SequencePropertyBean bean = retrieve( sequenceId,name);
       
    return table.remove(sequenceId + ":" + name) != null;
  }
View Full Code Here

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

    if (bean == null)
      return beans;

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

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

      boolean equal = true;

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

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

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

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

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

    StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(configCtx);
    SequencePropertyBeanMgr seqPropMgr = storageManager.getSequencePropretyBeanMgr();
   
    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;
        reason = "The message number of the message '" + messageNumber + "' exceeded the last message number '" + lastMessageNo + "'"+
                 "which was mentioned as last message in a previosly received application message";
      }
View Full Code Here

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

    StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(configCtx);
    SequencePropertyBeanMgr seqPropMgr = storageManager.getSequencePropretyBeanMgr();
   
    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 = "The sequence with the id " + sequenceID + " was closed previously. Cannot accept this message";
    }
   
    if (sequenceClosed) {
View Full Code Here

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

            .getAddress();
      } else {
        SequencePropertyBeanMgr seqPropMgr = storageManager
            .getSequencePropretyBeanMgr();
        String sequenceId = data.getSequenceId();
        SequencePropertyBean acksToBean = seqPropMgr.retrieve(
            sequenceId, Sandesha2Constants.SequenceProperties.ACKS_TO_EPR);
        if (acksToBean != null) {
          EndpointReference epr = new EndpointReference (acksToBean
              .getValue());
          if (epr != null)
            acksToStr = epr.getAddress();
        }
      }
View Full Code Here

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

    lastUpdatedTimeTransaction.commit();
   
    Transaction updataMsgStringTransaction = storageManager
        .getTransaction();
   
    SequencePropertyBean msgsBean = seqPropMgr.retrieve(sequenceId,
        Sandesha2Constants.SequenceProperties.SERVER_COMPLETED_MESSAGES);

    long msgNo = sequence.getMessageNumber().getMessageNumber();
    if (msgNo == 0) {
      String message = "Wrong message number";
      log.debug(message);
      throw new SandeshaException(message);
    }
   
    String key = SandeshaUtil.getUUID()//key to store the message.
   
    //updating the Highest_In_Msg_No property which gives the highest message number retrieved from this sequence.
    String highetsInMsgNoStr = SandeshaUtil.getSequenceProperty(sequenceId,Sandesha2Constants.SequenceProperties.HIGHEST_IN_MSG_NUMBER,configCtx);
    String highetsInMsgKey = SandeshaUtil.getSequenceProperty(sequenceId,Sandesha2Constants.SequenceProperties.HIGHEST_IN_MSG_KEY,configCtx);
   
    long highestInMsgNo=0;
    if (highetsInMsgNoStr!=null) {
      highestInMsgNo = Long.parseLong(highetsInMsgNoStr);
    }
   
    if (msgNo>highestInMsgNo) {
      highestInMsgNo = msgNo;
     
      String str = new Long(msgNo).toString();
      SequencePropertyBean highestMsgNoBean = new SequencePropertyBean (sequenceId,Sandesha2Constants.SequenceProperties.HIGHEST_IN_MSG_NUMBER,str);
      SequencePropertyBean highestMsgKeyBean = new SequencePropertyBean (sequenceId,Sandesha2Constants.SequenceProperties.HIGHEST_IN_MSG_KEY,key);
     
      if (highetsInMsgNoStr!=null) {
        seqPropMgr.update(highestMsgNoBean);
        seqPropMgr.update(highestMsgKeyBean);
      }else{
        seqPropMgr.insert(highestMsgNoBean);
        seqPropMgr.insert(highestMsgKeyBean);
      }
    }
   
    String messagesStr = "";
    if (msgsBean!=null)
      messagesStr = (String) msgsBean.getValue();
    else {
      msgsBean = new SequencePropertyBean ();
      msgsBean.setSequenceID(sequenceId);
      msgsBean.setName(Sandesha2Constants.SequenceProperties.SERVER_COMPLETED_MESSAGES);
      msgsBean.setValue(messagesStr);
    }
     

    if (msgNoPresentInList(messagesStr, msgNo)
        && (Sandesha2Constants.QOS.InvocationType.DEFAULT_INVOCATION_TYPE == Sandesha2Constants.QOS.InvocationType.EXACTLY_ONCE)) {
      //this is a duplicate message and the invocation type is
      // EXACTLY_ONCE.
      rmMsgCtx.pause();
    }

    if (messagesStr != "" && messagesStr != null)
      messagesStr = messagesStr + "," + Long.toString(msgNo);
    else
      messagesStr = Long.toString(msgNo);

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

    updataMsgStringTransaction.commit();

    Transaction invokeTransaction = storageManager.getTransaction();

    //  Pause the messages bean if not the right message to invoke.
    NextMsgBeanMgr mgr = storageManager.getNextMsgBeanMgr();
    NextMsgBean bean = mgr.retrieve(sequenceId);

    if (bean == null)
      throw new SandeshaException("Error- The sequence does not exist");

    InvokerBeanMgr storageMapMgr = storageManager.getStorageMapBeanMgr();
   
    //inorder invocation is still a global property
    boolean inOrderInvocation = SandeshaUtil.getPropertyBean(msgCtx.getConfigurationContext().getAxisConfiguration()).isInOrder();
   
    if (inOrderInvocation) {
     
      //pause the message
      rmMsgCtx.pause();
     
      SequencePropertyBean incomingSequenceListBean = (SequencePropertyBean) seqPropMgr
          .retrieve(
              Sandesha2Constants.SequenceProperties.ALL_SEQUENCES,
              Sandesha2Constants.SequenceProperties.INCOMING_SEQUENCE_LIST);

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

        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.insert(incomingSequenceListBean);
      }

      //saving the message.
View Full Code Here

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

    //saving the used message number
    if (!dummyMessage)
      setNextMsgNo(configContext,internalSequenceId,messageNumber);
     
    //set this as the response highest message.
    SequencePropertyBean responseHighestMsgBean = new SequencePropertyBean (
        internalSequenceId,
        Sandesha2Constants.SequenceProperties.HIGHEST_OUT_MSG_NUMBER,
        new Long (messageNumber).toString()
    );
    seqPropMgr.insert(responseHighestMsgBean);
   
    if (lastMessage) {
 
      SequencePropertyBean responseHighestMsgKeyBean = new SequencePropertyBean (
          internalSequenceId,
          Sandesha2Constants.SequenceProperties.HIGHEST_OUT_MSG_KEY,
          storageKey
      )
     
      SequencePropertyBean responseLastMsgKeyBean = new SequencePropertyBean (
          internalSequenceId,
          Sandesha2Constants.SequenceProperties.LAST_OUT_MESSAGE_NO,
          new Long (messageNumber).toString()
      )
     
      seqPropMgr.insert(responseHighestMsgKeyBean);
      seqPropMgr.insert(responseLastMsgKeyBean);
    }
   
    boolean sendCreateSequence = false;

    SequencePropertyBean outSeqBean = seqPropMgr.retrieve(
        internalSequenceId,
        Sandesha2Constants.SequenceProperties.OUT_SEQUENCE_ID);

    // setting async ack endpoint for the server side. (if present)
    if (serverSide) {
      String incomingSequenceID = SandeshaUtil
          .getServerSideIncomingSeqIdFromInternalSeqId(internalSequenceId);
      SequencePropertyBean incomingToBean = seqPropMgr.retrieve(
          incomingSequenceID,
          Sandesha2Constants.SequenceProperties.TO_EPR);
      if (incomingToBean != null) {
        String incomingTo = incomingToBean.getValue();
        msgContext.setProperty(SandeshaClientConstants.AcksTo, incomingTo);
      }
    }

   
    //FINDING THE SPEC VERSION
    String specVersion = null;
    if (msgContext.isServerSide()) {
      //in the server side, get the RM version from the request sequence.
      MessageContext requestMessageContext;
      try {
        requestMessageContext = msgContext.getOperationContext().getMessageContext(AxisOperationFactory.MESSAGE_LABEL_IN_VALUE);
      } catch (AxisFault e) {
        throw new SandeshaException (e);
      }
     
      if (requestMessageContext==null)
        throw new SandeshaException ("Request message context is null, cant find out the request side sequenceID");
     
      RMMsgContext requestRMMsgCtx = MsgInitializer.initializeMessage(requestMessageContext);
      Sequence sequence = (Sequence) requestRMMsgCtx.getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);
     
      String requestSequenceID = sequence.getIdentifier().getIdentifier();
      SequencePropertyBean specVersionBean = seqPropMgr.retrieve(requestSequenceID,Sandesha2Constants.SequenceProperties.RM_SPEC_VERSION);
      if (specVersionBean==null)
        throw new SandeshaException ("SpecVersion sequence property bean is not available for the incoming sequence. Cant find the RM version for outgoing side");
     
      specVersion = specVersionBean.getValue();
    } else {
      //in the client side, user will set the RM version.
      specVersion = (String) msgContext.getProperty(SandeshaClientConstants.RM_SPEC_VERSION);
    }
   
    if (specVersion==null)
      specVersion = SpecSpecificConstants.getDefaultSpecVersion();   //TODO change the default to v1_1.
   
    if (messageNumber == 1) {
      if (outSeqBean == null) { // out sequence will be set for the server side, in the case of an offer.
        sendCreateSequence = true;   // message number being one and not having an out sequence, implies that a create sequence has to be send.
      }

      // if fist message - setup the sending side sequence - both for the server and the client sides
      SequenceManager.setupNewClientSequence(msgContext, internalSequenceId,specVersion);
    }

    ServiceContext serviceContext = msgContext.getServiceContext();
    OperationContext operationContext = msgContext.getOperationContext();
   
    //SENDING THE CREATE SEQUENCE.
    if (sendCreateSequence) {
      SequencePropertyBean responseCreateSeqAdded = seqPropMgr
          .retrieve(internalSequenceId,Sandesha2Constants.SequenceProperties.OUT_CREATE_SEQUENCE_SENT);

      String addressingNamespaceURI = SandeshaUtil.getSequenceProperty(internalSequenceId,Sandesha2Constants.SequenceProperties.ADDRESSING_NAMESPACE_VALUE,configContext);
      String anonymousURI = SpecSpecificConstants.getAddressingAnonymousURI(addressingNamespaceURI);
     
      if (responseCreateSeqAdded == null) {
        responseCreateSeqAdded = new SequencePropertyBean(
            internalSequenceId,Sandesha2Constants.SequenceProperties.OUT_CREATE_SEQUENCE_SENT,"true");
        seqPropMgr.insert(responseCreateSeqAdded);

        String acksTo = null;
        if (serviceContext != null)
          acksTo = (String) msgContext.getProperty(SandeshaClientConstants.AcksTo);

        if (msgContext.isServerSide()) {
          // we do not set acksTo value to anonymous when the create
          // sequence is send from the server.
          MessageContext requestMessage;
          try {
            requestMessage = operationContext.getMessageContext(OperationContextFactory.MESSAGE_LABEL_IN_VALUE);
          } catch (AxisFault e) {
            throw new SandeshaException (e);
          }
         
          if (requestMessage == null) {
            String message = "Request message is not present";
            log.debug(message);
            throw new SandeshaException(message);
          }
          acksTo = requestMessage.getTo().getAddress();

        } else {
          if (acksTo == null)
            acksTo = anonymousURI;
        }

        if (!anonymousURI.equals(acksTo) && !serverSide) {
          String transportIn = (String) configContext   //TODO verify
              .getProperty(MessageContext.TRANSPORT_IN);
          if (transportIn == null)
            transportIn = org.apache.axis2.Constants.TRANSPORT_HTTP;
        } else if (acksTo == null && serverSide) {
          String incomingSequencId = SandeshaUtil.getServerSideIncomingSeqIdFromInternalSeqId(internalSequenceId);
          SequencePropertyBean bean = seqPropMgr.retrieve(
              incomingSequencId,Sandesha2Constants.SequenceProperties.REPLY_TO_EPR);
          if (bean != null) {
            EndpointReference acksToEPR = new EndpointReference(bean.getValue());
            if (acksToEPR != null)
              acksTo = (String) acksToEPR.getAddress();
          }
        } else if (anonymousURI.equals(acksTo)) {
          // set transport in.
View Full Code Here

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

   
    SequenceOffer offer = createSequencePart.getSequenceOffer();
    if (offer != null) {
      String offeredSequenceId = offer.getIdentifer().getIdentifier();

      SequencePropertyBean offeredSequenceBean = new SequencePropertyBean();
      offeredSequenceBean.setName(Sandesha2Constants.SequenceProperties.OFFERED_SEQUENCE);
      offeredSequenceBean.setSequenceID(internalSequenceId);
      offeredSequenceBean.setValue(offeredSequenceId);

      seqPropMgr.insert(offeredSequenceBean);
    }

    MessageContext createSeqMsg = createSeqRMMessage.getMessageContext();
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.