Package org.apache.sandesha2.storage.beanmanagers

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


    } else {

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

      SenderBeanMgr senderBeanMgr = storageManager.getSenderBeanMgr();

      String key = SandeshaUtil.getUUID();

      SenderBean ackBean = new SenderBean();
      ackBean.setMessageContextRefKey(key);
      ackBean.setMessageID(ackMsgCtx.getMessageID());
      ackBean.setReSend(false);
      ackBean.setSequenceID(sequencePropertyKey);
      EndpointReference to = ackMsgCtx.getTo();
      if (to!=null)
        ackBean.setToAddress(to.getAddress());

      // this will be set to true in the sender.
      ackBean.setSend(true);

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

      ackBean.setMessageType(Sandesha2Constants.MessageTypes.ACK);
      long ackInterval = SandeshaUtil.getPropertyBean(rmMsgCtx.getMessageContext().getAxisOperation())
          .getAcknowledgementInterval();

      // Ack will be sent as stand alone, only after the retransmitter
      // interval.
      long timeToSend = System.currentTimeMillis() + ackInterval;

      // removing old acks.
      SenderBean findBean = new SenderBean();
      findBean.setMessageType(Sandesha2Constants.MessageTypes.ACK);

      // this will be set to true in the sandesha2TransportSender.
      findBean.setSend(true);
      findBean.setReSend(false);
      Collection coll = senderBeanMgr.find(findBean);
      Iterator it = coll.iterator();

      if (it.hasNext()) {
        SenderBean oldAckBean = (SenderBean) it.next();
        timeToSend = oldAckBean.getTimeToSend(); // If there is an
                              // old ack. This ack
                              // will be sent in
                              // the old
                              // timeToSend.

        // removing the retransmitted entry for the oldAck
        senderBeanMgr.delete(oldAckBean.getMessageID());

        // removing the message store entry for the old ack
        storageManager.removeMessageContext(oldAckBean.getMessageContextRefKey());
      }

      ackBean.setTimeToSend(timeToSend);
      storageManager.storeMessageContext(key, ackMsgCtx);

      ackMsgCtx.setProperty(Sandesha2Constants.QUALIFIED_FOR_SENDING, Sandesha2Constants.VALUE_FALSE);
     
      // inserting the new ack.
      senderBeanMgr.insert(ackBean);
      // / asyncAckTransaction.commit();

      // passing the message through sandesha2sender
      ackMsgCtx.setProperty(Sandesha2Constants.SET_SEND_TO_TRUE, Sandesha2Constants.VALUE_TRUE);
      ackRMMsgCtx = MsgInitializer.initializeMessage(ackMsgCtx);
View Full Code Here


    CreateSequence createSequencePart = (CreateSequence) createSeqRMMessage
        .getMessagePart(Sandesha2Constants.MessageParts.CREATE_SEQ);

    SequencePropertyBeanMgr seqPropMgr = storageManager.getSequencePropertyBeanMgr();
    RMSBeanMgr rmsBeanMgr = storageManager.getRMSBeanMgr();
    SenderBeanMgr senderBeanMgr = storageManager.getSenderBeanMgr();

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

      SequencePropertyBean offeredSequenceBean = new SequencePropertyBean();
      offeredSequenceBean.setName(Sandesha2Constants.SequenceProperties.OFFERED_SEQUENCE);
      offeredSequenceBean.setSequencePropertyKey(sequencePropertyKey);
      offeredSequenceBean.setValue(offeredSequenceId);

      seqPropMgr.insert(offeredSequenceBean);
    }

    MessageContext createSeqMsg = createSeqRMMessage.getMessageContext();
    createSeqMsg.setRelationships(null); // create seq msg does not
                        // relateTo anything

    String createSequenceMessageStoreKey = SandeshaUtil.getUUID(); // the key taht will be used to store
                                     //the create sequence message.
   
    RMSBean rmsBean = new RMSBean();
    rmsBean.setInternalSequenceID(internalSequenceId);
    rmsBean.setCreateSeqMsgID(createSeqMsg.getMessageID());
    rmsBean.setCreateSequenceMsgStoreKey(createSequenceMessageStoreKey);
   
    //cloning the message and storing it as a reference.
    MessageContext clonedMessage = SandeshaUtil.cloneMessageContext(createSeqMsg);
    String clonedMsgStoreKey = SandeshaUtil.getUUID();
    storageManager.storeMessageContext(clonedMsgStoreKey, clonedMessage);
    rmsBean.setReferenceMessageStoreKey(clonedMsgStoreKey);
   
   
    //TODO set the replyTo of CreateSeq (and others) to Anymomous if Application Msgs hv it as Anonymous.
   
//    //checking weather the sequence is in polling mode.
//    boolean pollingMode = false;
//    EndpointReference replyTo = applicationRMMsg.getReplyTo();
//    if (replyTo!=null && SandeshaUtil.isWSRMAnonymousReplyTo(replyTo.getAddress()))
//      pollingMode = true;
//    else if (replyTo!=null && offer!=null &&
//        (AddressingConstants.Final.WSA_ANONYMOUS_URL.equals(replyTo.getAddress()) ||
//            AddressingConstants.Submission.WSA_ANONYMOUS_URL.equals(replyTo.getAddress())))
//      pollingMode = true;
//   
//    createSeqBean.setPollingMode(pollingMode);
   
//    //if PollingMode is true, starting the pollingmanager.
//    if (pollingMode)
//      SandeshaUtil.startPollingManager(configCtx);
   
    SecurityToken token = (SecurityToken) createSeqRMMessage.getProperty(Sandesha2Constants.SequenceProperties.SECURITY_TOKEN);
    if(token != null) {
      SecurityManager secManager = SandeshaUtil.getSecurityManager(configCtx);
      rmsBean.setSecurityTokenData(secManager.getTokenRecoveryData(token));
     
      // If we are using token based security, and the 1.1 spec level, then we
      // should introduce a UsesSequenceSTR header into the message.
      if(createSequencePart.getNamespaceValue().equals(Sandesha2Constants.SPEC_2006_08.NS_URI)) {
        UsesSequenceSTR header = new UsesSequenceSTR(null, Sandesha2Constants.SPEC_2006_08.NS_URI);
        header.toSOAPEnvelope(createSeqMsg.getEnvelope());
      }
    }
   
    rmsBeanMgr.insert(rmsBean);

    String addressingNamespaceURI = SandeshaUtil.getSequenceProperty(sequencePropertyKey,
        Sandesha2Constants.SequenceProperties.ADDRESSING_NAMESPACE_VALUE, storageManager);
    String anonymousURI = SpecSpecificConstants.getAddressingAnonymousURI(addressingNamespaceURI);

    if (createSeqMsg.getReplyTo() == null)
      createSeqMsg.setReplyTo(new EndpointReference(anonymousURI));

    SenderBean createSeqEntry = new SenderBean();
    createSeqEntry.setMessageContextRefKey(createSequenceMessageStoreKey);
    createSeqEntry.setTimeToSend(System.currentTimeMillis());
    createSeqEntry.setMessageID(createSeqRMMessage.getMessageId());
    createSeqEntry.setInternalSequenceID(sequencePropertyKey);
    // this will be set to true in the sender
    createSeqEntry.setSend(true);
    EndpointReference to = createSeqRMMessage.getTo();
    if (to!=null)
      createSeqEntry.setToAddress(to.getAddress());

    createSeqMsg.setProperty(Sandesha2Constants.QUALIFIED_FOR_SENDING, Sandesha2Constants.VALUE_FALSE);
    storageManager.storeMessageContext(createSequenceMessageStoreKey, createSeqMsg); // storing the message
   
    senderBeanMgr.insert(createSeqEntry);

    SandeshaUtil.executeAndStore(createSeqRMMessage, createSequenceMessageStoreKey);
   
    if (log.isDebugEnabled())
      log.debug("Exit: ApplicationMsgProcessor::addCreateSequenceMessage");
View Full Code Here

      log.debug("Enter: ApplicationMsgProcessor::processResponseMessage, " + internalSequenceId);

    MessageContext msg = rmMsg.getMessageContext();

    SequencePropertyBeanMgr sequencePropertyMgr = storageManager.getSequencePropertyBeanMgr();
    SenderBeanMgr senderBeanMgr = storageManager.getSenderBeanMgr();


    // again - looks weird in the client side - but consistent
    SequencePropertyBean outSequenceBean = sequencePropertyMgr.retrieve(internalSequenceId,
        Sandesha2Constants.SequenceProperties.OUT_SEQUENCE_ID);


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

    String rmNamespaceValue = SpecSpecificConstants.getRMNamespaceValue(rmVersion);

    Sequence sequence = new Sequence(rmNamespaceValue);
    MessageNumber msgNumber = new MessageNumber(rmNamespaceValue);
    msgNumber.setMessageNumber(messageNumber);
    sequence.setMessageNumber(msgNumber);

    // setting last message
    if (msg.isServerSide()) {
      MessageContext requestMsg = null;

      requestMsg = msg.getOperationContext()
          .getMessageContext(OperationContextFactory.MESSAGE_LABEL_IN_VALUE);

      RMMsgContext reqRMMsgCtx = MsgInitializer.initializeMessage(requestMsg);
      Sequence requestSequence = (Sequence) reqRMMsgCtx.getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);
      if (requestSequence == null) {
        String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.requestSeqIsNull);
        log.debug(message);
        throw new SandeshaException(message);
      }

      if (requestSequence.getLastMessage() != null) {
        sequence.setLastMessage(new LastMessage(rmNamespaceValue));
      }

    } else {
      // client side

      OperationContext operationContext = msg.getOperationContext();
      if (operationContext != null) {
        Object obj = msg.getProperty(SandeshaClientConstants.LAST_MESSAGE);
        if (obj != null && "true".equals(obj)) {

          SequencePropertyBean specVersionBean = sequencePropertyMgr.retrieve(internalSequenceId,
              Sandesha2Constants.SequenceProperties.RM_SPEC_VERSION);
          if (specVersionBean == null)
            throw new SandeshaException(SandeshaMessageHelper
                .getMessage(SandeshaMessageKeys.specVersionNotSet));

          String specVersion = specVersionBean.getValue();
          if (SpecSpecificConstants.isLastMessageIndicatorRequired(specVersion))
            sequence.setLastMessage(new LastMessage(rmNamespaceValue));
        }
      }
    }

    AckRequested ackRequested = null;

    boolean addAckRequested = false;
    // if (!lastMessage)
    // addAckRequested = true; //TODO decide the policy to add the
    // ackRequested tag

    // setting the Sequnece id.
    // Set send = true/false depending on the availability of the out
    // sequence id.
    String identifierStr = null;
    if (outSequenceBean == null || outSequenceBean.getValue() == null) {
      identifierStr = Sandesha2Constants.TEMP_SEQUENCE_ID;

    } else {
      identifierStr = outSequenceBean.getValue();
    }

    Identifier id1 = new Identifier(rmNamespaceValue);
    id1.setIndentifer(identifierStr);
    sequence.setIdentifier(id1);
    rmMsg.setMessagePart(Sandesha2Constants.MessageParts.SEQUENCE, sequence);

    if (addAckRequested) {
      ackRequested = new AckRequested(rmNamespaceValue);
      Identifier id2 = new Identifier(rmNamespaceValue);
      id2.setIndentifer(identifierStr);
      ackRequested.setIdentifier(id2);
      rmMsg.setMessagePart(Sandesha2Constants.MessageParts.ACK_REQUEST, ackRequested);
    }


    rmMsg.addSOAPEnvelope();


    // Retransmitter bean entry for the application message
    SenderBean appMsgEntry = new SenderBean();

    appMsgEntry.setMessageContextRefKey(storageKey);

    appMsgEntry.setTimeToSend(System.currentTimeMillis());
    appMsgEntry.setMessageID(rmMsg.getMessageId());
    appMsgEntry.setMessageNumber(messageNumber);
    appMsgEntry.setMessageType(Sandesha2Constants.MessageTypes.APPLICATION);
    if (outSequenceBean == null || outSequenceBean.getValue() == null) {
      appMsgEntry.setSend(false);
    } else {
      appMsgEntry.setSend(true);
      // Send will be set to true at the sender.
      msg.setProperty(Sandesha2Constants.SET_SEND_TO_TRUE, Sandesha2Constants.VALUE_TRUE);
    }
   
    EndpointReference to = rmMsg.getTo();
    if (to!=null)
      appMsgEntry.setToAddress(to.getAddress());
   
    appMsgEntry.setInternalSequenceID(internalSequenceId);
    storageManager.storeMessageContext(storageKey, msg);

    msg.setProperty(Sandesha2Constants.QUALIFIED_FOR_SENDING, Sandesha2Constants.VALUE_FALSE);
    senderBeanMgr.insert(appMsgEntry);

    // increasing the current handler index, so that the message will not be
    // going throught the SandeshaOutHandler again.
    msg.setCurrentHandlerIndex(msg.getCurrentHandlerIndex() + 1);
View Full Code Here

  private static void cleanSendingSideData(ConfigurationContext configContext, String sequencePropertyKey,String internalSequenceId,
      boolean serverSide, StorageManager storageManager) throws SandeshaException {

    SequencePropertyBeanMgr sequencePropertyBeanMgr = storageManager.getSequencePropertyBeanMgr();
    SenderBeanMgr senderBeanMgr = storageManager.getSenderBeanMgr();
    RMSBeanMgr rmsBeanMgr = storageManager.getRMSBeanMgr();

    String outSequenceID = SandeshaUtil.getSequenceProperty(sequencePropertyKey,
        Sandesha2Constants.SequenceProperties.OUT_SEQUENCE_ID, storageManager);

    if (!serverSide) {
      boolean stopListnerForAsyncAcks = false;
      SequencePropertyBean acksToBean = sequencePropertyBeanMgr.retrieve(sequencePropertyKey,
          Sandesha2Constants.SequenceProperties.ACKS_TO_EPR);

      String addressingNamespace = SandeshaUtil.getSequenceProperty(sequencePropertyKey,
          Sandesha2Constants.SequenceProperties.ADDRESSING_NAMESPACE_VALUE, storageManager);
      String anonymousURI = SpecSpecificConstants.getAddressingAnonymousURI(addressingNamespace);

      if (acksToBean != null) {
        String acksTo = acksToBean.getValue();
        if (acksTo != null && !anonymousURI.equals(acksTo)) {
          stopListnerForAsyncAcks = true;
        }
      }
    }

    // removing retransmitterMgr entries and corresponding message contexts.
    Collection collection = senderBeanMgr.find(internalSequenceId);
    Iterator iterator = collection.iterator();
    while (iterator.hasNext()) {
      SenderBean senderBean = (SenderBean) iterator.next();
      senderBeanMgr.delete(senderBean.getMessageID());

      String messageStoreKey = senderBean.getMessageContextRefKey();
      storageManager.removeMessageContext(messageStoreKey);
    }
View Full Code Here

   
    EndpointReference to = terminateRMMessage.getTo();
    if (to!=null)
      terminateBean.setToAddress(to.getAddress());

    SenderBeanMgr senderBeanMgr = storageManager.getSenderBeanMgr();

    senderBeanMgr.insert(terminateBean);

    SequencePropertyBean terminateAdded = new SequencePropertyBean();
    terminateAdded.setName(Sandesha2Constants.SequenceProperties.TERMINATE_ADDED);
    terminateAdded.setSequencePropertyKey(outSequenceId);
    terminateAdded.setValue("true");
View Full Code Here

      StorageManager storageManager =
        SandeshaUtil.getSandeshaStorageManager(serverConfigContext, serverConfigContext.getAxisConfiguration());
     
      Transaction tran = storageManager.getTransaction();
     
      RMDBean finderBean = new RMDBean();
      List rmdBeans = storageManager.getRMDBeanMgr().find(finderBean);
     
      tran.commit();
     
      lastError = null;
     
      if (rmdBeans.isEmpty())
        lastError = new Error("rmdBeans empty " + rmdBeans);
      else {
        RMDBean bean = (RMDBean)rmdBeans.get(0);
        if (bean.isTerminated())
          break;
       
        lastError = new Error("RMDBean not deleted " + bean);
      }
    }

    if(lastError != null) throw lastError;

    while(System.currentTimeMillis() < limit) {
      Thread.sleep(tickTime); // Try the assertions each tick interval, until they pass or we time out
     
      // Check that the sequence has been deleted.
      StorageManager storageManager =
        SandeshaUtil.getSandeshaStorageManager(serverConfigContext, serverConfigContext.getAxisConfiguration());
     
      Transaction tran = storageManager.getTransaction();
     
      RMDBean finderBean = new RMDBean();
      List rmdBeans = storageManager.getRMDBeanMgr().find(finderBean);
     
      tran.commit();
     
      lastError = null;
View Full Code Here

      StorageManager storageManager =
        SandeshaUtil.getSandeshaStorageManager(configContext, configContext.getAxisConfiguration());
     
      Transaction tran = storageManager.getTransaction();
     
      RMSBean finderBean = new RMSBean();
      List rmsBeans = storageManager.getRMSBeanMgr().find(finderBean);
     
      tran.commit();
     
      lastError = null;
View Full Code Here

    messageContext.setEnvelope(dummyEnvelope);
   
    RMMsgContext applicationRMMsg = new RMMsgContext(messageContext);
   
    // Create an RMSBean so the create sequence message can be created
    RMSBean rmsBean = new RMSBean();
    rmsBean.setRMVersion(Sandesha2Constants.SPEC_VERSIONS.v1_1);
    rmsBean.setToEPR(to);
    rmsBean.setAcksToEPR(AddressingConstants.Final.WSA_NONE_URI);
       
    // Create a Create Sequence message
    // generating a new create sequeuce message.
    RMMsgContext createSeqRMMessage = RMMsgCreator.createCreateSeqMsg(rmsBean, applicationRMMsg);
    messageContext = createSeqRMMessage.getMessageContext();
    messageContext.setWSAAction(SpecSpecificConstants.getCreateSequenceAction(Sandesha2Constants.SPEC_VERSIONS.v1_1));

    CreateSequence createSeqResPart = (CreateSequence) createSeqRMMessage
    .getMessagePart(Sandesha2Constants.MessageParts.CREATE_SEQ);

    createSeqResPart.setAcksTo(
        new AcksTo(new EndpointReference(AddressingConstants.Final.WSA_NONE_URI),
                   SpecSpecificConstants.getRMNamespaceValue(rmsBean.getRMVersion()),
                   AddressingConstants.Final.WSA_NAMESPACE));
   
    // Update the SOAP Envelope of the message
    createSeqRMMessage.addSOAPEnvelope();
View Full Code Here

    CreateSequence createSeqResPart = (CreateSequence) createSeqRMMessage
    .getMessagePart(Sandesha2Constants.MessageParts.CREATE_SEQ);

    createSeqResPart.setAcksTo(
        new AcksTo(new EndpointReference(AddressingConstants.Final.WSA_NONE_URI),
                   SpecSpecificConstants.getRMNamespaceValue(rmsBean.getRMVersion()),
                   AddressingConstants.Final.WSA_NAMESPACE));
   
    // Update the SOAP Envelope of the message
    createSeqRMMessage.addSOAPEnvelope();
View Full Code Here

    // generating a new create sequeuce message.
    RMMsgContext createSeqRMMessage = RMMsgCreator.createCreateSeqMsg(rmsBean, applicationRMMsg);
    messageContext = createSeqRMMessage.getMessageContext();
    messageContext.setWSAAction(SpecSpecificConstants.getCreateSequenceAction(Sandesha2Constants.SPEC_VERSIONS.v1_1));

    CreateSequence createSeqResPart = (CreateSequence) createSeqRMMessage
    .getMessagePart(Sandesha2Constants.MessageParts.CREATE_SEQ);

    createSeqResPart.setAcksTo(
        new AcksTo(new EndpointReference(AddressingConstants.Final.WSA_NONE_URI),
                   SpecSpecificConstants.getRMNamespaceValue(rmsBean.getRMVersion()),
                   AddressingConstants.Final.WSA_NAMESPACE));
   
    // Update the SOAP Envelope of the message
View Full Code Here

TOP

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

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.