Package org.apache.sandesha2.storage.beans

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


    ConfigurationContext configurationContext = referenceRMMessage.getMessageContext().getConfigurationContext();
    StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(configurationContext);
    SequencePropertyBeanMgr seqPropMgr = storageManager.getSequencePropretyBeanMgr();
   
    //Setting the ack depending on AcksTo.
    SequencePropertyBean acksToBean = seqPropMgr.retrieve(sequenceID,
        Sandesha2Constants.SequenceProperties.ACKS_TO_EPR);

    EndpointReference acksTo = new EndpointReference(acksToBean.getValue());
    String acksToStr = acksTo.getAddress();

    if (acksToStr == null)
      throw new SandeshaException(
          "acksToStr Seqeunce property is not set correctly");
View Full Code Here


    while (iterator.hasNext()) {
      InvokerBean storageMapBean = (InvokerBean) iterator.next();
      storageMapBeanMgr.delete(storageMapBean.getKey());
    }
   
    SequencePropertyBean allSequenceBean = sequencePropertyBeanMgr.retrieve(Sandesha2Constants.SequenceProperties.ALL_SEQUENCES,Sandesha2Constants.SequenceProperties.INCOMING_SEQUENCE_LIST);
    ArrayList allSequenceList = (ArrayList) allSequenceBean.getValue();
   
    allSequenceList.remove(sequenceID);
  }
View Full Code Here

    StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(configContext);
    SequencePropertyBeanMgr sequencePropertyBeanMgr = storageManager.getSequencePropretyBeanMgr();
    SenderBeanMgr retransmitterBeanMgr = storageManager.getRetransmitterBeanMgr();
    CreateSeqBeanMgr createSeqBeanMgr = storageManager.getCreateSeqBeanMgr();
   
    SequencePropertyBean internalSequenceBean = sequencePropertyBeanMgr.retrieve(sequenceID,Sandesha2Constants.SequenceProperties.INTERNAL_SEQUENCE_ID);
    if (internalSequenceBean==null)
      throw new SandeshaException ("TempSequence entry not found");
   
    String internalSequenceId = (String) internalSequenceBean.getValue();
   
    //removing retransmitterMgr entries
    SenderBean findRetransmitterBean = new SenderBean ();
    findRetransmitterBean.setInternalSequenceId(internalSequenceId);
    Collection collection = retransmitterBeanMgr.find(findRetransmitterBean);
    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();
      sequencePropertyBeanMgr.delete(sequencePropertyBean.getSequenceId(),sequencePropertyBean.getName());
    }
   
    SequencePropertyBean findSequencePropertyBean2 = new SequencePropertyBean ();
    findSequencePropertyBean2.setSequenceId(internalSequenceId);
    collection = sequencePropertyBeanMgr.find(findSequencePropertyBean2);
    iterator = collection.iterator();
    while (iterator.hasNext()) {
      SequencePropertyBean sequencePropertyBean = (SequencePropertyBean) iterator.next();
      sequencePropertyBeanMgr.delete(sequencePropertyBean.getSequenceId(),sequencePropertyBean.getName());
    }
   
  }
View Full Code Here

      throw new SandeshaException(
          "Application message does not contain a sequence part");

    String sequenceId = sequence.getIdentifier().getIdentifier();

    SequencePropertyBean internalSequenceBean = sequencePropertyBeanMgr
        .retrieve(sequenceId,
            Sandesha2Constants.SequenceProperties.INTERNAL_SEQUENCE_ID);
    if (internalSequenceBean == null)
      throw new SandeshaException("Temp Sequence is not set");

    String internalSequenceId = (String) internalSequenceBean.getValue();
    findBean.setInternalSequenceId(internalSequenceId);
    findBean.setMessagetype(Sandesha2Constants.MessageTypes.ACK);

    Collection collection = retransmitterBeanMgr.find(findBean);
    Iterator it = collection.iterator();
View Full Code Here

    ConfigurationContext configCtx = rmMsgCtx.getMessageContext()
        .getConfigurationContext();
    if (configCtx == null)
      throw new SandeshaException("Configuration Context is null");

    SequencePropertyBean msgsBean = seqPropMgr.retrieve(sequenceId,
        Sandesha2Constants.SequenceProperties.RECEIVED_MESSAGES);

    long msgNo = sequence.getMessageNumber().getMessageNumber();
    if (msgNo == 0)
      throw new SandeshaException("Wrong message number");

    String messagesStr = (String) msgsBean.getValue();

    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.

      msgCtx.setPausedTrue(new QName(Sandesha2Constants.IN_HANDLER_NAME));

    }

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

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

    sendAckIfNeeded(rmMsgCtx, messagesStr);

    //  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();

    long nextMsgno = bean.getNextMsgNoToProcess();

    if (msgCtx.isServerSide()) {
      boolean inOrderInvocation = PropertyManager.getInstance().isInOrderInvocation();
      if (inOrderInvocation) {
        //pause the message
        msgCtx.setPausedTrue(new QName(Sandesha2Constants.IN_HANDLER_NAME));

        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);

          seqPropMgr.insert(incomingSequenceListBean);
        }

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

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

        //saving the message.
        try {
          String key = SandeshaUtil.storeMessageContext(rmMsgCtx
              .getMessageContext());
          storageMapMgr.insert(new InvokerBean(key, msgNo,
              sequenceId));

          //This will avoid performing application processing more
          // than
          // once.
          rmMsgCtx.setProperty(Sandesha2Constants.APPLICATION_PROCESSING_DONE,
              "true");

        } catch (Exception ex) {
          throw new SandeshaException(ex.getMessage());
        }

        //Starting the invoker if stopped.
        SandeshaUtil.startInvokerIfStopped(msgCtx.getConfigurationContext());

      }
    }

    try {
      MessageContext requestMessage = rmMsgCtx.getMessageContext()
          .getOperationContext().getMessageContext(
              WSDLConstants.MESSAGE_LABEL_IN_VALUE);
      String requestMessageId = requestMessage.getMessageID();
      SequencePropertyBean checkResponseBean = seqPropMgr.retrieve(
          requestMessageId,
          Sandesha2Constants.SequenceProperties.CHECK_RESPONSE);
      if (checkResponseBean != null) {
        checkResponseBean.setValue(msgCtx);
        seqPropMgr.update(checkResponseBean);
      }

    } catch (AxisFault e) {
      throw new SandeshaException(e.getMessage());
View Full Code Here

    AckRequested ackRequested = (AckRequested) rmMsgCtx
        .getMessagePart(Sandesha2Constants.MessageParts.ACK_REQUEST);
    LastMessage lastMessage = (LastMessage) sequence.getLastMessage();

    //Setting the ack depending on AcksTo.
    SequencePropertyBean acksToBean = seqPropMgr.retrieve(sequenceId,
        Sandesha2Constants.SequenceProperties.ACKS_TO_EPR);

    EndpointReference acksTo = (EndpointReference) acksToBean.getValue();
    String acksToStr = acksTo.getAddress();

    if (acksToStr == null || messagesStr == null)
      throw new SandeshaException(
          "Seqeunce properties are not set correctly");
View Full Code Here

            .getCreateSeqBeanMgr();

        //Setting sequence properties.
        SequencePropertyBeanMgr seqPropMgr = storageManager
            .getSequencePropretyBeanMgr();
        SequencePropertyBean outSequenceBean = new SequencePropertyBean();
        outSequenceBean
            .setName(Sandesha2Constants.SequenceProperties.OUT_SEQUENCE_ID);
        outSequenceBean.setValue(outSequenceId);
        outSequenceBean.setSequenceId(newSequenceId);
        seqPropMgr.insert(outSequenceBean);

        //Temp sequence id should be set for the server side.
        //If internal sequence id is not set. this implies server side.
        SequencePropertyBean internalSeqBean = seqPropMgr.retrieve(
            outSequenceId,
            Sandesha2Constants.SequenceProperties.INTERNAL_SEQUENCE_ID);
        if (internalSeqBean == null) {
          SequencePropertyBean internalSequenceBean = new SequencePropertyBean();
          internalSequenceBean
              .setName(Sandesha2Constants.SequenceProperties.INTERNAL_SEQUENCE_ID);
          internalSequenceBean.setSequenceId(outSequenceId);
          internalSequenceBean.setValue(newSequenceId);
          seqPropMgr.insert(internalSequenceBean);
        }

      }

      CreateSequence createSeq = (CreateSequence) createSeqRMMsg
          .getMessagePart(Sandesha2Constants.MessageParts.CREATE_SEQ);
      if (createSeq == null)
        throw new AxisFault(
            "Create sequence part not present in the create sequence message");

      EndpointReference acksTo = createSeq.getAcksTo().getAddress()
          .getEpr();
      if (acksTo == null || acksTo.getAddress() == null
          || acksTo.getAddress() == "")
        throw new AxisFault(
            "Acks to not present in the create sequence message");

      SequencePropertyBean seqPropBean = new SequencePropertyBean(
          newSequenceId, Sandesha2Constants.SequenceProperties.ACKS_TO_EPR,
          acksTo);

      StorageManager storageManager = SandeshaUtil
          .getSandeshaStorageManager(context);
View Full Code Here

    Iterator nackIterator = sequenceAck.getNackList().iterator();
    String outSequenceId = sequenceAck.getIdentifier().getIdentifier();
    if (outSequenceId == null || "".equals(outSequenceId))
      throw new SandeshaException("OutSequenceId is null");

    SequencePropertyBean internalSequenceBean = seqPropMgr.retrieve(
        outSequenceId, Sandesha2Constants.SequenceProperties.INTERNAL_SEQUENCE_ID);

    if (internalSequenceBean == null || internalSequenceBean.getValue() == null)
      throw new SandeshaException("TempSequenceId is not set correctly");

    String internalSequenceId = (String) internalSequenceBean.getValue();

    //Following happens in the SandeshaGlobal handler
    rmMsgCtx.getMessageContext()
        .setProperty(Sandesha2Constants.ACK_PROCSSED, "true");

    //Removing relatesTo - Some WSRM endpoints tend to set relatesTo value
    // for ack messages.
    //Because of this dispatching may go wrong.
    //So we set relatesTo value to null for ackMessages. (this happens in
    // the SandeshaGlobal handler)
    //Do this only if this is a standalone ACK.
    if (rmMsgCtx.getMessageType() == Sandesha2Constants.MessageTypes.ACK)
      rmMsgCtx.setRelatesTo(null);

    SenderBean input = new SenderBean();
    input.setInternalSequenceId(internalSequenceId);
    Collection retransmitterEntriesOfSequence = retransmitterMgr
        .find(input);

    while (ackRangeIterator.hasNext()) {
      AcknowledgementRange ackRange = (AcknowledgementRange) ackRangeIterator
          .next();
      long lower = ackRange.getLowerValue();
      long upper = ackRange.getUpperValue();

      for (long messageNo = lower; messageNo <= upper; messageNo++) {
        SenderBean retransmitterBean = getRetransmitterEntry(
            retransmitterEntriesOfSequence, messageNo);
        if (retransmitterBean != null)
          retransmitterMgr.delete(retransmitterBean.getMessageId());
      }
    }

    while (nackIterator.hasNext()) {
      Nack nack = (Nack) nackIterator.next();
      long msgNo = nack.getNackNumber();

      //TODO - Process Nack
    }

    //following get called in the SandesaInHandler
    //if (justSendTerminateIfNeeded) {
    //If all messages up to last message have been acknowledged.
    //Add terminate Sequence message.
    SequencePropertyBean lastOutMsgBean = seqPropMgr.retrieve(
        internalSequenceId, Sandesha2Constants.SequenceProperties.LAST_OUT_MESSAGE);
    if (lastOutMsgBean != null) {
      Long lastOutMsgNoLng = (Long) lastOutMsgBean.getValue();
      if (lastOutMsgNoLng == null)
        throw new SandeshaException(
            "Invalid object set for the Last Out Message");

      long lastOutMessageNo = lastOutMsgNoLng.longValue();
View Full Code Here

            .getConfigurationContext());

    SequencePropertyBeanMgr seqPropMgr = storageManager
        .getSequencePropretyBeanMgr();

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

    if (terminated != null && terminated.getValue() != null
        && "true".equals(terminated.getValue())) {
      System.out.println("TERMINATE WAS ADDED PREVIOUSLY....");
      return;
    }

    RMMsgContext terminateRMMessage = RMMsgCreator
        .createTerminateSequenceMessage(incomingAckRMMsg, outSequenceId);

    SequencePropertyBean toBean = seqPropMgr.retrieve(internalSequenceId,
        Sandesha2Constants.SequenceProperties.TO_EPR);

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

    terminateRMMessage.setTo(new EndpointReference(toEPR.getAddress()));
    terminateRMMessage.setFrom(new EndpointReference(
        Sandesha2Constants.WSA.NS_URI_ANONYMOUS));
    terminateRMMessage.setFaultTo(new EndpointReference(
        Sandesha2Constants.WSA.NS_URI_ANONYMOUS));
    terminateRMMessage
        .setWSAAction(Sandesha2Constants.WSRM.Actions.ACTION_TERMINATE_SEQUENCE);
    terminateRMMessage
        .setSOAPAction(Sandesha2Constants.WSRM.Actions.SOAP_ACTION_TERMINATE_SEQUENCE);

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

    String key = SandeshaUtil.storeMessageContext(terminateRMMessage
        .getMessageContext());
    SenderBean terminateBean = new SenderBean();
    terminateBean.setKey(key);

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

    terminateBean.setMessageId(terminateRMMessage.getMessageId());
    terminateBean.setSend(true);
    terminateBean.setReSend(false);

    SenderBeanMgr retramsmitterMgr = storageManager
        .getRetransmitterBeanMgr();

    SequencePropertyBean terminateAdded = new SequencePropertyBean();
    terminateAdded.setName(Sandesha2Constants.SequenceProperties.TERMINATE_ADDED);
    terminateAdded.setSequenceId(outSequenceId);
    terminateAdded.setValue("true");

    seqPropMgr.insert(terminateAdded);

    retramsmitterMgr.insert(terminateBean);
View Full Code Here

    retransmitterMgr.delete(createSeqMsgId);

    //storing new out sequence id
    SequencePropertyBeanMgr sequencePropMgr = storageManager
        .getSequencePropretyBeanMgr();
    SequencePropertyBean outSequenceBean = new SequencePropertyBean(
        internalSequenceId, Sandesha2Constants.SequenceProperties.OUT_SEQUENCE_ID,
        newOutSequenceId);
    SequencePropertyBean internalSequenceBean = new SequencePropertyBean(
        newOutSequenceId,
        Sandesha2Constants.SequenceProperties.INTERNAL_SEQUENCE_ID, internalSequenceId);
    sequencePropMgr.insert(outSequenceBean);
    sequencePropMgr.insert(internalSequenceBean);

    //processing for accept (offer has been sent)
    Accept accept = createSeqResponsePart.getAccept();
    if (accept != null) {
      //Find offered sequence from internal sequence id.
      SequencePropertyBean offeredSequenceBean = sequencePropMgr
          .retrieve(internalSequenceId,
              Sandesha2Constants.SequenceProperties.OFFERED_SEQUENCE);

      //TODO this should be detected in the Fault manager.
      if (offeredSequenceBean == null)
        throw new SandeshaException(
            "No offered sequence. But an accept was received");

      String offeredSequenceId = (String) offeredSequenceBean.getValue();

      EndpointReference acksToEPR = accept.getAcksTo().getAddress()
          .getEpr();
      SequencePropertyBean acksToBean = new SequencePropertyBean();
      acksToBean.setName(Sandesha2Constants.SequenceProperties.ACKS_TO_EPR);
      acksToBean.setSequenceId(offeredSequenceId);
      acksToBean.setValue(acksToEPR);

      sequencePropMgr.insert(acksToBean);

      NextMsgBean nextMsgBean = new NextMsgBean();
      nextMsgBean.setSequenceId(offeredSequenceId);
View Full Code Here

TOP

Related Classes of org.apache.sandesha2.storage.beans.SequencePropertyBean

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.