Examples of SenderBeanMgr


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

    ConfigurationContext configCtx = msgCtx.getConfigurationContext();

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

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

    String outSequenceId = sequenceAck.getIdentifier().getIdentifier();
    if (outSequenceId == null || "".equals(outSequenceId)) {
      String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.outSeqIDIsNull);
      log.debug(message);
      throw new SandeshaException(message);
    }
   
    String internalSequenceId = SandeshaUtil.getSequenceProperty(outSequenceId,
        Sandesha2Constants.SequenceProperties.INTERNAL_SEQUENCE_ID, storageManager);

    //here we cannot get the property key using the usual SandeshaUtil.getSequencePropertyKey function,
    //because this can be a applicationMessage, which piggybacks the acknowledgement.
    String sequencePropertyKey = internalSequenceId;

    // Check that the sender of this Ack holds the correct token
    SequencePropertyBean tokenBean = seqPropMgr.retrieve(outSequenceId, Sandesha2Constants.SequenceProperties.SECURITY_TOKEN);
    if(tokenBean != null) {
      SecurityManager secManager = SandeshaUtil.getSecurityManager(configCtx);
      SecurityToken token = secManager.recoverSecurityToken(tokenBean.getValue());
     
      secManager.checkProofOfPossession(token, soapHeader, msgCtx);
    }
   
    Iterator ackRangeIterator = sequenceAck.getAcknowledgementRanges().iterator();
    Iterator nackIterator = sequenceAck.getNackList().iterator();

    FaultManager faultManager = new FaultManager();
    SandeshaException fault = faultManager
        .checkForUnknownSequence(rmMsgCtx, outSequenceId, storageManager);
    if(fault == null) {
      fault = faultManager.checkForInvalidAcknowledgement(rmMsgCtx, storageManager);
    }
    if (fault != null) {
      throw fault;
    }

    // updating the last activated time of the sequence.
    SequenceManager.updateLastActivatedTime(sequencePropertyKey, storageManager);

    SenderBean input = new SenderBean();
    input.setSend(true);
    input.setReSend(true);
    Collection retransmitterEntriesOfSequence = senderBeanMgr.find(input);

    ArrayList ackedMessagesList = new ArrayList();
    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 = getSenderEntry(retransmitterEntriesOfSequence, messageNo);
        if (retransmitterBean != null) {
          senderBeanMgr.delete(retransmitterBean.getMessageID());

          // removing the application message from the storage.
          String storageKey = retransmitterBean.getMessageContextRefKey();
          storageManager.removeMessageContext(storageKey);
        }
View Full Code Here

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

      log.debug("Enter: AcknowledgementManager::piggybackAcksIfPresent");
   

    ConfigurationContext configurationContext = rmMessageContext.getConfigurationContext();

    SenderBeanMgr senderBeanMgr = storageManager.getSenderBeanMgr();

    SenderBean findBean = new SenderBean();

    findBean.setMessageType(Sandesha2Constants.MessageTypes.ACK);
    findBean.setSend(true);
    findBean.setReSend(false);

    String carrietTo = rmMessageContext.getTo().getAddress();

    Collection collection = senderBeanMgr.find(findBean);

    Iterator it = collection.iterator();

    piggybackLoop: while (it.hasNext()) {
      SenderBean ackBean = (SenderBean) it.next();

      long timeNow = System.currentTimeMillis();
      if (ackBean.getTimeToSend() > timeNow) {
        // //Piggybacking will happen only if the end of ack interval
        // (timeToSend) is not reached.

        MessageContext ackMsgContext = storageManager.retrieveMessageContext(ackBean.getMessageContextRefKey(),
            configurationContext);

        // wsa:To has to match for piggybacking.
        String to = ackMsgContext.getTo().getAddress();
        if (!carrietTo.equals(to)) {
          continue piggybackLoop;
        }

        if (log.isDebugEnabled()) log.debug("Adding ack headers");

        // deleting the ack entry.
        senderBeanMgr.delete(ackBean.getMessageID());

        // Adding the ack(s) to the application message
        boolean acks = false;
        SOAPHeader appMsgHeaders = rmMessageContext.getMessageContext().getEnvelope().getHeader();
       
View Full Code Here

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

      log.error(message);
      throw new SandeshaException(message);
    }
    String createSeqMsgId = relatesTo.getValue();

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

    RMSBean rmsBean = rmsBeanMgr.retrieve(createSeqMsgId);
    if (rmsBean == null) {
      String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.createSeqEntryNotFound);
      log.debug(message);
      throw new SandeshaException(message);
    }

    // Check that the create sequence response message proves possession of the correct token
    String tokenData = rmsBean.getSecurityTokenData();
    if(tokenData != null) {
      SecurityManager secManager = SandeshaUtil.getSecurityManager(configCtx);
      MessageContext crtSeqResponseCtx = createSeqResponseRMMsgCtx.getMessageContext();
      OMElement body = crtSeqResponseCtx.getEnvelope().getBody();
      SecurityToken token = secManager.recoverSecurityToken(tokenData);
      secManager.checkProofOfPossession(token, body, crtSeqResponseCtx);
    }

    String internalSequenceId = rmsBean.getInternalSequenceID();
    if (internalSequenceId == null || "".equals(internalSequenceId)) {
      String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.tempSeqIdNotSet);
      log.debug(message);
      throw new SandeshaException(message);
    }
    createSeqResponseRMMsgCtx.setProperty(Sandesha2Constants.MessageContextProperties.INTERNAL_SEQUENCE_ID,internalSequenceId);
   
    String sequencePropertyKey = SandeshaUtil.getSequencePropertyKey(createSeqResponseRMMsgCtx);
   
    rmsBean.setSequenceID(newOutSequenceId);
    rmsBeanMgr.update(rmsBean);

    SenderBean createSequenceSenderBean = senderBeanMgr.retrieve(createSeqMsgId);
    if (createSequenceSenderBean == null)
      throw new SandeshaException(SandeshaMessageHelper.getMessage(SandeshaMessageKeys.createSeqEntryNotFound));

    // deleting the create sequence entry.
    senderBeanMgr.delete(createSeqMsgId);

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

    sequencePropMgr.insert(outSequenceBean);
    sequencePropMgr.insert(internalSequenceBean);
   
    // Store the security token under the new sequence id
    if(tokenData != null) {
      SequencePropertyBean newToken = new SequencePropertyBean(newOutSequenceId,
          Sandesha2Constants.SequenceProperties.SECURITY_TOKEN, tokenData);
      sequencePropMgr.insert(newToken);
    }

    // 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(sequencePropertyKey,
          Sandesha2Constants.SequenceProperties.OFFERED_SEQUENCE);

      // TODO this should be detected in the Fault manager.
      if (offeredSequenceBean == null) {
        String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.accptButNoSequenceOffered);
        log.debug(message);
        throw new SandeshaException(message);
      }

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

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

      sequencePropMgr.insert(acksToBean);

      RMDBean rmdBean = new RMDBean();
      rmdBean.setSequenceID(offeredSequenceId);
      rmdBean.setNextMsgNoToProcess(1);
     

      boolean pollingMode = false;
      if (Sandesha2Constants.SPEC_VERSIONS.v1_1.equals(createSeqResponseRMMsgCtx.getRMSpecVersion())) {
        String replyToAddress = SandeshaUtil.getSequenceProperty(sequencePropertyKey,
                Sandesha2Constants.SequenceProperties.REPLY_TO_EPR, storageManager);
        if (replyToAddress!=null) {
          if (AddressingConstants.Submission.WSA_ANONYMOUS_URL.equals(replyToAddress))
            pollingMode = true;
          else if (AddressingConstants.Final.WSA_ANONYMOUS_URL.equals(replyToAddress))
            pollingMode = true;
          else if (replyToAddress.startsWith(Sandesha2Constants.WSRM_ANONYMOUS_URI_PREFIX))
            pollingMode = true;
        }
      }
     
      //Storing the referenceMessage of the sending side sequence as the reference message
      //of the receiving side as well.
      //This can be used when creating new outgoing messages.
     
      String referenceMsgStoreKey = rmsBean.getReferenceMessageStoreKey();
      MessageContext referenceMsg = storageManager.retrieveMessageContext(referenceMsgStoreKey, configCtx);
     
      String newMessageStoreKey = SandeshaUtil.getUUID();
      storageManager.storeMessageContext(newMessageStoreKey,referenceMsg);
     
      rmdBean.setReferenceMessageKey(newMessageStoreKey);
     
      rmdBean.setPollingMode(pollingMode);
     
      //if PollingMode is true, starting the pollingmanager.
      if (pollingMode)
        SandeshaUtil.startPollingManager(configCtx);
     
      RMDBeanMgr rmdBeanMgr = storageManager.getRMDBeanMgr();
      rmdBeanMgr.insert(rmdBean);

      String rmSpecVersion = createSeqResponseRMMsgCtx.getRMSpecVersion();

      SequencePropertyBean specVersionBean = new SequencePropertyBean(offeredSequenceId,
          Sandesha2Constants.SequenceProperties.RM_SPEC_VERSION, rmSpecVersion);
      sequencePropMgr.insert(specVersionBean);

      SequencePropertyBean receivedMsgBean = new SequencePropertyBean(offeredSequenceId,
          Sandesha2Constants.SequenceProperties.SERVER_COMPLETED_MESSAGES, "");
      sequencePropMgr.insert(receivedMsgBean);

      SequencePropertyBean msgsBean = new SequencePropertyBean();
      msgsBean.setSequencePropertyKey(offeredSequenceId);
      msgsBean.setName(Sandesha2Constants.SequenceProperties.CLIENT_COMPLETED_MESSAGES);
      msgsBean.setValue("");
      sequencePropMgr.insert(msgsBean);

      // setting the addressing version.
      String addressingNamespace = createSeqResponseRMMsgCtx.getAddressingNamespaceValue();
      SequencePropertyBean addressingVersionBean = new SequencePropertyBean(offeredSequenceId,
          Sandesha2Constants.SequenceProperties.ADDRESSING_NAMESPACE_VALUE, addressingNamespace);
      sequencePropMgr.insert(addressingVersionBean);

      // Store the security token for the offered sequence
      if(tokenData != null) {
        SequencePropertyBean newToken = new SequencePropertyBean(offeredSequenceId,
            Sandesha2Constants.SequenceProperties.SECURITY_TOKEN, tokenData);
        sequencePropMgr.insert(newToken);
      }
    }

    SenderBean target = new SenderBean();
    target.setInternalSequenceID(internalSequenceId);
    target.setSend(false);
    target.setReSend(true);

    Iterator iterator = senderBeanMgr.find(target).iterator();
    while (iterator.hasNext()) {
      SenderBean tempBean = (SenderBean) iterator.next();

      // updating the application message
      String key = tempBean.getMessageContextRefKey();
      MessageContext applicationMsg = storageManager.retrieveMessageContext(key, configCtx);

      // TODO make following exception message more understandable to the
      // user (probably some others exceptions messages as well)
      if (applicationMsg == null)
        throw new SandeshaException(SandeshaMessageHelper.getMessage(SandeshaMessageKeys.unavailableAppMsg));

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

      String assumedRMNamespace = SpecSpecificConstants.getRMNamespaceValue(rmVersion);

      RMMsgContext applicaionRMMsg = MsgInitializer.initializeMessage(applicationMsg);

      Sequence sequencePart = (Sequence) applicaionRMMsg.getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);
      if (sequencePart == null) {
        String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.seqPartIsNull);
        log.debug(message);
        throw new SandeshaException(message);
      }

      Identifier identifier = new Identifier(assumedRMNamespace);
      identifier.setIndentifer(newOutSequenceId);

      sequencePart.setIdentifier(identifier);

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

      // asking to send the application msssage
      tempBean.setSend(true);
      senderBeanMgr.update(tempBean);

      // updating the message. this will correct the SOAP envelope string.
      storageManager.updateMessageContext(key, applicationMsg);
    }
View Full Code Here

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

        throw new SandeshaException(e1.getMessage());
      }

    } else {

      SenderBeanMgr senderBeanMgr = storageManager.getSenderBeanMgr();

      String key = SandeshaUtil.getUUID();

      // dumping to the storage will be done be Sandesha2 Transport Sender
      // storageManager.storeMessageContext(key,ackMsgCtx);

      SenderBean ackBean = new SenderBean();
      ackBean.setMessageContextRefKey(key);
      ackBean.setMessageID(ackMsgCtx.getMessageID());
      ackBean.setReSend(false);
      ackBean.setSequenceID(sequenceId);
     
      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);

      // the internalSequenceId value of the retransmitter Table for the
      // messages related to an incoming
      // sequence is the actual sequence ID

      // operation is the lowest level, Sandesha2 can be engaged.
      SandeshaPolicyBean propertyBean = SandeshaUtil.getPropertyBean(msgContext.getAxisOperation());

      long ackInterval = propertyBean.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.
        senderBeanMgr.delete(oldAckBean.getMessageID());
      }

      ackBean.setTimeToSend(timeToSend);

      storageManager.storeMessageContext(key, ackMsgCtx);
      msgContext.setProperty(Sandesha2Constants.QUALIFIED_FOR_SENDING, Sandesha2Constants.VALUE_FALSE);
     
      // inserting the new ack.
      senderBeanMgr.insert(ackBean);

      // passing the message through sandesha2sender

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

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

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

    ackRequestBean.setReSend(false);

    SenderBeanMgr senderBeanMgr = storageManager.getSenderBeanMgr();

    senderBeanMgr.insert(ackRequestBean);

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

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

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

    Identifier identifier = makeConnection.getIdentifier();
   
    ConfigurationContext configurationContext = rmMsgCtx.getConfigurationContext();
    StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(configurationContext,configurationContext.getAxisConfiguration());
   
    SenderBeanMgr senderBeanMgr = storageManager.getSenderBeanMgr();
   
    //selecting the set of SenderBeans that suit the given criteria.
    SenderBean findSenderBean = new SenderBean ();
    findSenderBean.setSend(true);
   
    if (address!=null)
      findSenderBean.setWsrmAnonURI(address.getAddress());
   
    if (identifier!=null)
      findSenderBean.setSequenceID(identifier.getIdentifier());
   
    //finding the beans that go with the criteria of the passed SenderBean
   
    //beans with reSend=true
    findSenderBean.setReSend(true);
    Collection collection = senderBeanMgr.find(findSenderBean);
   
    //beans with reSend=false
    findSenderBean.setReSend (false);
    Collection collection2 = senderBeanMgr.find(findSenderBean);
   
    //all possible beans
    collection.addAll(collection2);
   
    //selecting a bean to send RANDOMLY. TODO- Should use a better mechanism.
View Full Code Here

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

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

    closeBean.setReSend(false);

    SenderBeanMgr senderBeanMgr = storageManager.getSenderBeanMgr();

    senderBeanMgr.insert(closeBean);


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

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

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

    Transaction transaction = null;
   
    try {
      StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(configurationContext, configurationContext.getAxisConfiguration());
      SenderBeanMgr senderBeanMgr = storageManager.getSenderBeanMgr();

      transaction = storageManager.getTransaction();

      String key = senderBean.getMessageContextRefKey();
      MessageContext msgCtx = null;
      RMMsgContext   rmMsgCtx = null;
      if(messageToSend != null) {
        msgCtx = messageToSend.getMessageContext();
        rmMsgCtx = messageToSend;
      } else {
        msgCtx = storageManager.retrieveMessageContext(key, configurationContext);
     
        if (msgCtx == null) {
          // This sender bean has already been processed
         
          if(transaction != null && transaction.isActive()) transaction.commit();
          transaction = null;

          return;
        }
     
        rmMsgCtx = MsgInitializer.initializeMessage(msgCtx);
      }

      // sender will not send the message if following property is
      // set and not true.
      // But it will set if it is not set (null)

      // This is used to make sure that the mesage get passed the
      // Sandesha2TransportSender.

      String qualifiedForSending = (String) msgCtx.getProperty(Sandesha2Constants.QUALIFIED_FOR_SENDING);
      if (qualifiedForSending != null && !qualifiedForSending.equals(Sandesha2Constants.VALUE_TRUE)) {
        if (log.isDebugEnabled())
          log.debug("Exit: SenderWorker::run, !qualified for sending");
       
        if(transaction != null && transaction.isActive()) {
          transaction.commit();
          transaction = null;
        }
       
        return;
      }

      if (msgCtx == null) {
        if (log.isDebugEnabled())
          log.debug(SandeshaMessageHelper.getMessage(SandeshaMessageKeys.sendHasUnavailableMsgEntry));
       
        if(transaction != null && transaction.isActive()) {
          transaction.commit();
          transaction = null;
        }
       
        return;     
      }

      // operation is the lowest level Sandesha2 should be attached
      ArrayList msgsNotToSend = SandeshaUtil.getPropertyBean(msgCtx.getAxisOperation()).getMsgTypesToDrop();

      if (msgsNotToSend != null && msgsNotToSend.contains(new Integer(rmMsgCtx.getMessageType()))) {
        if (log.isDebugEnabled())
          log.debug("Exit: SenderWorker::run, message type to be dropped " + rmMsgCtx.getMessageType());
       
        if(transaction != null && transaction.isActive()) {
          transaction.commit();
          transaction = null;
        }
       
        return
      }

      // If we are sending to the anonymous URI then we _must_ have a transport waiting,
      // or the message can't go anywhere. If there is nothing here then we leave the
      // message in the sender queue, and a MakeConnection (or a retransmitted request)
      // will hopefully pick it up soon.
      Boolean makeConnection = (Boolean) msgCtx.getProperty(Sandesha2Constants.MAKE_CONNECTION_RESPONSE);
      EndpointReference toEPR = msgCtx.getTo();

      MessageContext inMsg = null;
      OperationContext op = msgCtx.getOperationContext();
     
      RequestResponseTransport t = (RequestResponseTransport) msgCtx.getProperty(RequestResponseTransport.TRANSPORT_CONTROL);
     
      if (t==null) {
        if (op != null)
          inMsg = op.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
        if (inMsg != null)
          t = (RequestResponseTransport) inMsg.getProperty(RequestResponseTransport.TRANSPORT_CONTROL);
      }

      // If we are anonymous, and this is not a makeConnection, then we must have a transport waiting
      if((toEPR==null || toEPR.hasAnonymousAddress()) &&
         (makeConnection == null || !makeConnection.booleanValue()) &&
         (t != null && !t.getStatus().equals(RequestResponseTransportStatus.WAITING))) {
       
        // Mark this sender bean so that we know that the transport is unavailable, if the
        // bean is still stored.
        SenderBean bean = senderBeanMgr.retrieve(senderBean.getMessageID());
        if(bean != null && bean.isTransportAvailable()) {
          bean.setTransportAvailable(false);
          senderBeanMgr.update(bean);
        }
       
        // Commit the update
        if(transaction != null && transaction.isActive()) transaction.commit();
        transaction = null;
       
        if (log.isDebugEnabled())
          log.debug("Exit: SenderWorker::run, no response transport for anonymous message");
        return;
      }
     
      //if the message belong to the Replay Model, it will be send out only if


      boolean continueSending = updateMessage(rmMsgCtx,senderBean,storageManager);
      //save changes done @ updateMessage -> MessageRetransmissionAdjuster.adjustRetransmittion
      storageManager.getSenderBeanMgr().update(senderBean);
     

      if (!continueSending) {
        if (log.isDebugEnabled())
          log.debug("Exit: SenderWorker::run, !continueSending");
       
        if(transaction != null && transaction.isActive()) {
          transaction.commit();
          transaction = null;
        }
        invokeCallBackObject(storageManager,msgCtx ,"Exit: SenderWorker::run, !continueSending");
        return;
      }

      int messageType = senderBean.getMessageType();
     
      if (isAckPiggybackableMsgType(messageType)) {
        // Commit the update
        if(transaction != null && transaction.isActive()) transaction.commit();
        transaction = storageManager.getTransaction();

        // Piggyback ack messages based on the 'To' address of the message
        transaction = AcknowledgementManager.piggybackAcksIfPresent(rmMsgCtx, storageManager, transaction);
      }

      // sending the message
      boolean successfullySent = false;

      // Although not actually sent yet, update the send count to indicate an attempt
      if (senderBean.isReSend()) {
        SenderBean bean2 = senderBeanMgr.retrieve(senderBean.getMessageID());
        if (bean2 != null) {
          bean2.setSentCount(senderBean.getSentCount());
          senderBeanMgr.update(bean2);
        }
      }

      // have to commit the transaction before sending. This may
      // get changed when WS-AT is available.
      if(transaction != null) {
        transaction.commit();
        transaction = null;
      }

      msgCtx.getOptions().setTimeOutInMilliSeconds(1000000);
     
      boolean processResponseForFaults = false ;
      try {
        InvocationResponse response = InvocationResponse.CONTINUE;
       
        SandeshaPolicyBean policy = SandeshaUtil.getPropertyBean(msgCtx.getAxisOperation());
        if(policy.isUseMessageSerialization()) {
          if(msgCtx.isPaused()) {
            if (log.isDebugEnabled())
              log.debug("Resuming a send for message : " + msgCtx.getEnvelope().getHeader());
            msgCtx.setPaused(false);
            msgCtx.setProperty(MessageContext.TRANSPORT_NON_BLOCKING, Boolean.FALSE);
            response = AxisEngine.resumeSend(msgCtx);
          } else {
            if (log.isDebugEnabled())
              log.debug("Sending a message : " + msgCtx.getEnvelope().getHeader());
            msgCtx.setProperty(MessageContext.TRANSPORT_NON_BLOCKING, Boolean.FALSE);
            AxisEngine.send(msgCtx)// TODO check if this should return an invocation response
          }
        } else {
          // had to fully build the SOAP envelope to support
          // retransmissions.
          // Otherwise a 'parserAlreadyAccessed' exception could
          // get thrown in retransmissions.
          // But this has a performance reduction.
          msgCtx.getEnvelope().build();
 
          ArrayList retransmittablePhases = (ArrayList) msgCtx.getProperty(Sandesha2Constants.RETRANSMITTABLE_PHASES);
          if (retransmittablePhases!=null) {
            msgCtx.setExecutionChain(retransmittablePhases);
          } else {
            ArrayList emptyExecutionChain = new ArrayList ();
            msgCtx.setExecutionChain(emptyExecutionChain);
          }
         
          msgCtx.setCurrentHandlerIndex(0);
          msgCtx.setCurrentPhaseIndex(0);
          msgCtx.setPaused(false);
       
          if (log.isDebugEnabled())
            log.debug("Resuming a send for message : " + msgCtx.getEnvelope().getHeader());
          response = AxisEngine.resumeSend(msgCtx);
        }
        if(log.isDebugEnabled()) log.debug("Engine resume returned " + response);
        if(response != InvocationResponse.SUSPEND) {
          if(t != null) {
            if(log.isDebugEnabled()) log.debug("Signalling transport in " + t);
            t.signalResponseReady();
          }
        }
       
        successfullySent = true;
       
      } catch (AxisFault e) {
        //this is a possible SOAP 1.2 Fault. So letting it proceed.
       
        processResponseForFaults = true;
       
        recordError(e, rmMsgCtx, storageManager);
       
      } catch (Exception e) {
        String message = SandeshaMessageHelper.getMessage(
            SandeshaMessageKeys.sendMsgError, e.toString());
       
        if (log.isErrorEnabled())
          log.error(message, e);
       
        recordError(e, rmMsgCtx, storageManager);
       
      }
      // Establish the transaction for post-send processing
      transaction = storageManager.getTransaction();

      // update or delete only if the object is still present.
      SenderBean bean1 = senderBeanMgr
          .retrieve(senderBean.getMessageID());
      if (bean1 != null) {
        if (senderBean.isReSend()) {
          bean1.setTimeToSend(senderBean.getTimeToSend());
          senderBeanMgr.update(bean1);
        }
      }

      // Commit the transaction to release the SenderBean
View Full Code Here

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

      makeConnectionSenderBean.setSequenceID(rmBean.getSequenceID());
      EndpointReference to = makeConnectionRMMessage.getTo();
      if (to!=null)
        makeConnectionSenderBean.setToAddress(to.getAddress());

      SenderBeanMgr senderBeanMgr = storageManager.getSenderBeanMgr();
     
      //this message should not be sent until it is qualified. I.e. till it is sent through the Sandesha2TransportSender.
      makeConnectionRMMessage.setProperty(Sandesha2Constants.QUALIFIED_FOR_SENDING, Sandesha2Constants.VALUE_FALSE);
     
      SandeshaUtil.executeAndStore(makeConnectionRMMessage, makeConnectionMsgStoreKey);
     
      senderBeanMgr.insert(makeConnectionSenderBean);     
    }
   
    if(log.isDebugEnabled()) log.debug("Exit: PollingManager::pollForSequence");
  }
View Full Code Here

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

        }
       
        return false;
      }
     
      SenderBeanMgr mgr = storageManager.getSenderBeanMgr();
      SenderBean senderBean = mgr.getNextMsgToSend(sequenceId);
     
     
     
      if (senderBean == null ||
          (!senderBean.isReSend() && senderBean.getSentCount()>0)) {
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.