Package org.apache.sandesha2.storage.beanmanagers

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


    }

    StorageManager storageManager = SandeshaUtil
        .getSandeshaStorageManager(rmMsgCtx.getMessageContext()
            .getConfigurationContext());
    SequencePropertyBeanMgr seqPropMgr = storageManager
        .getSequencePropretyBeanMgr();

    //setting acked msg no range
    Sequence sequence = (Sequence) rmMsgCtx
        .getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);
    String sequenceId = sequence.getIdentifier().getIdentifier();
    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


    SOAPFactory factory = SOAPAbstractFactory.getSOAPFactory(SandeshaUtil
        .getSOAPVersion(msgCtx.getEnvelope()));
    StorageManager storageManager = SandeshaUtil
        .getSandeshaStorageManager(msgCtx.getConfigurationContext());
    SequencePropertyBeanMgr seqPropMgr = storageManager
        .getSequencePropretyBeanMgr();

    Sequence sequence = (Sequence) rmMsgCtx
        .getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);
    String sequenceId = sequence.getIdentifier().getIdentifier();
    ConfigurationContext configCtx = rmMsgCtx.getMessageContext()
        .getConfigurationContext();
    if (configCtx == null)
      throw new SandeshaException("Configuration Context is null");

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

            .getSandeshaStorageManager(context);
        CreateSeqBeanMgr createSeqMgr = storageManager
            .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);
      SequencePropertyBeanMgr seqPropMgr = storageManager
          .getSequencePropretyBeanMgr();
      seqPropMgr.insert(seqPropBean);
      outMessage.setResponseWritten(true);

      Object obj1 = createSeqMsg.getOperationContext().getProperty(
          org.apache.axis2.Constants.RESPONSE_WRITTEN);
View Full Code Here

    StorageManager storageManager = SandeshaUtil
        .getSandeshaStorageManager(rmMsgCtx.getMessageContext()
            .getConfigurationContext());
    SenderBeanMgr retransmitterMgr = storageManager
        .getRetransmitterBeanMgr();
    SequencePropertyBeanMgr seqPropMgr = storageManager
        .getSequencePropretyBeanMgr();

    Iterator ackRangeIterator = sequenceAck.getAcknowledgementRanges()
        .iterator();

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

    StorageManager storageManager = SandeshaUtil
        .getSandeshaStorageManager(incomingAckRMMsg.getMessageContext()
            .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

    //deleting the create sequence entry.
    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);
      nextMsgBean.setNextMsgNoToProcess(1);
View Full Code Here

            reason = "A sequence with offered sequenceId, already axists";
          }

          //checking weather an outgoing sequence with the given id
          // exists.
          SequencePropertyBeanMgr sequencePropertyBeanMgr = storageManager
              .getSequencePropretyBeanMgr();
          SequencePropertyBean sequencePropertyBean = sequencePropertyBeanMgr
              .retrieve(
                  sequenceId,
                  Sandesha2Constants.SequenceProperties.OUT_SEQUENCE_ID);
          if (sequencePropertyBean != null) {
            String outSequenceId = (String) sequencePropertyBean
View Full Code Here

        CreateSequence createSequence = (CreateSequence) referenceRMMsgContext
            .getMessagePart(Sandesha2Constants.MessageParts.CREATE_SEQ);
        acksToStr = createSequence.getAcksTo().getAddress().getEpr()
            .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 = (EndpointReference) acksToBean
              .getValue();
          if (epr != null)
View Full Code Here

              .getMessageContext().getConfigurationContext());
    } catch (SandeshaException e) {
      e.printStackTrace();
    }

    SequencePropertyBeanMgr seqPropMgr = storageManager
        .getSequencePropretyBeanMgr();

    SequencePropertyBean receivedMsgBean = new SequencePropertyBean(
        sequenceId, Sandesha2Constants.SequenceProperties.RECEIVED_MESSAGES, "");
    SequencePropertyBean toBean = new SequencePropertyBean(sequenceId,
        Sandesha2Constants.SequenceProperties.TO_EPR, replyTo);
    SequencePropertyBean replyToBean = new SequencePropertyBean(sequenceId,
        Sandesha2Constants.SequenceProperties.REPLY_TO_EPR, to);
    SequencePropertyBean acksToBean = new SequencePropertyBean(sequenceId,
        Sandesha2Constants.SequenceProperties.ACKS_TO_EPR, acksTo);

    seqPropMgr.insert(receivedMsgBean);
    seqPropMgr.insert(toBean);
    seqPropMgr.insert(replyToBean);
    seqPropMgr.insert(acksToBean);

    NextMsgBeanMgr nextMsgMgr = storageManager.getNextMsgBeanMgr();
    nextMsgMgr.insert(new NextMsgBean(sequenceId, 1)); // 1 will be the next
    // message to invoke
    //this will apply for only in-order invocations.
View Full Code Here

    StorageManager storageManager = SandeshaUtil
        .getSandeshaStorageManager(firstAplicationMsgCtx
            .getConfigurationContext());

    SequencePropertyBeanMgr seqPropMgr = storageManager
        .getSequencePropretyBeanMgr();

    EndpointReference toEPR = firstAplicationMsgCtx.getTo();
    EndpointReference replyToEPR = firstAplicationMsgCtx.getReplyTo();
    String acksTo = (String) firstAplicationMsgCtx
        .getProperty(Sandesha2ClientAPI.AcksTo);

    if (toEPR == null)
      throw new SandeshaException("WS-Addressing To is null");

    SequencePropertyBean toBean = new SequencePropertyBean(iternalSequenceId,
        Sandesha2Constants.SequenceProperties.TO_EPR, toEPR);

    //Default value for acksTo is anonymous
    if (acksTo == null)
      acksTo = Sandesha2Constants.WSA.NS_URI_ANONYMOUS;

    EndpointReference acksToEPR = new EndpointReference(acksTo);
    SequencePropertyBean acksToBean = new SequencePropertyBean(
        iternalSequenceId, Sandesha2Constants.SequenceProperties.ACKS_TO_EPR,
        acksToEPR);
    seqPropMgr.insert(toBean);
    seqPropMgr.insert(acksToBean);

  }
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.