Package org.apache.sandesha2.storage

Examples of org.apache.sandesha2.storage.StorageManager


    MessageContext msgContext = ackRequestRMMsg.getMessageContext();
    ConfigurationContext configurationContext = msgContext.getConfigurationContext();
    Options options = msgContext.getOptions();

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

    SequencePropertyBeanMgr seqPropMgr = storageManager.getSequencePropertyBeanMgr();

    String toAddress = ackRequestRMMsg.getTo().getAddress();
    String sequenceKey = (String) options.getProperty(SandeshaClientConstants.SEQUENCE_KEY);
    String internalSeqenceID = SandeshaUtil.getInternalSequenceID(toAddress, sequenceKey);

    String outSequenceID = SandeshaUtil.getSequenceProperty(internalSeqenceID,
        Sandesha2Constants.SequenceProperties.OUT_SEQUENCE_ID, storageManager);
    if (outSequenceID == null)
      throw new SandeshaException(SandeshaMessageHelper.getMessage(
          SandeshaMessageKeys.couldNotSendAckRequestSeqNotFound, internalSeqenceID));


    // registring an InOutOperationContext for this.
    // since the serviceContext.fireAndForget only sets a inOnly One
    // this does not work when there is a terminateSequnceResponse
    // TODO do processing of terminateMessagesCorrectly., create a new
    // message instead of sendign the one given by the serviceClient
    // TODO important

    AxisOperation outInAxisOp = new OutInAxisOperation(new QName("temp"));

    AxisOperation referenceInOutOperation = msgContext.getAxisService()
        .getOperation(
            new QName(Sandesha2Constants.RM_IN_OUT_OPERATION_NAME));
    if (referenceInOutOperation == null) {
      String messge = "Cant find the recerence RM InOut operation";
      throw new SandeshaException(messge);
    }

    outInAxisOp.setParent(msgContext.getAxisService());
    // setting flows
    // outInAxisOp.setRemainingPhasesInFlow(referenceInOutOperation.getRemainingPhasesInFlow());
    outInAxisOp.setRemainingPhasesInFlow(referenceInOutOperation
        .getRemainingPhasesInFlow());

    OperationContext opcontext = OperationContextFactory
        .createOperationContext(
            WSDL20_2004Constants.MEP_CONSTANT_OUT_IN, outInAxisOp);
    opcontext.setParent(msgContext.getServiceContext());
    configurationContext.registerOperationContext(ackRequestRMMsg.getMessageId(),
        opcontext);

    msgContext.setOperationContext(opcontext);
    msgContext.setAxisOperation(outInAxisOp);
   
    Iterator iterator = ackRequestRMMsg.getMessageParts(Sandesha2Constants.MessageParts.ACK_REQUEST);
   
    AckRequested ackRequested = null;
    while (iterator.hasNext()) {
      ackRequested = (AckRequested) iterator.next();
    }
   
    if (iterator.hasNext()) {
      String message = "Passed message has more than one AckRequest. You can have only one";
      throw new SandeshaException (message);
    }
   
    if (ackRequested==null) {
      String message = "No AckRequested part was present in the message";
      throw new SandeshaException (message);
    }
   
    ackRequested.getIdentifier().setIndentifer(outSequenceID);
   
    ackRequestRMMsg.setFlow(MessageContext.OUT_FLOW);
    msgContext.setProperty(Sandesha2Constants.APPLICATION_PROCESSING_DONE, "true");

    ackRequestRMMsg.setTo(new EndpointReference(toAddress));

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

    ackRequestRMMsg.setWSAAction(SpecSpecificConstants.getAckRequestAction (rmVersion));
    ackRequestRMMsg.setSOAPAction(SpecSpecificConstants.getAckRequestSOAPAction (rmVersion));

    String transportTo = SandeshaUtil.getSequenceProperty(internalSeqenceID,
        Sandesha2Constants.SequenceProperties.TRANSPORT_TO, storageManager);
    if (transportTo != null) {
      ackRequestRMMsg.setProperty(MessageContextConstants.TRANSPORT_URL, transportTo);
    }
   
   
    //setting msg context properties
    ackRequestRMMsg.setProperty(Sandesha2Constants.MessageContextProperties.SEQUENCE_ID, outSequenceID);
    ackRequestRMMsg.setProperty(Sandesha2Constants.MessageContextProperties.INTERNAL_SEQUENCE_ID, internalSeqenceID);
    ackRequestRMMsg.setProperty(Sandesha2Constants.MessageContextProperties.SEQUENCE_PROPERTY_KEY , sequenceKey);

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

    String key = SandeshaUtil.getUUID();

    SenderBean ackRequestBean = new SenderBean();
    ackRequestBean.setMessageContextRefKey(key);

    storageManager.storeMessageContext(key, msgContext);

    // 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.
    ackRequestBean.setTimeToSend(System.currentTimeMillis());

    ackRequestBean.setMessageID(msgContext.getMessageID());
   
    EndpointReference to = msgContext.getTo();
    if (to!=null)
      ackRequestBean.setToAddress(to.getAddress());
   
    // this will be set to true at the sender.
    ackRequestBean.setSend(true);

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


   */
  private static boolean validateMessage(RMMsgContext rmMsgCtx) throws SandeshaException {

    ConfigurationContext configContext = rmMsgCtx.getMessageContext().getConfigurationContext();
    AxisConfiguration axisConfiguration = configContext.getAxisConfiguration();
    StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(configContext, axisConfiguration);
    SequencePropertyBeanMgr sequencePropertyBeanMgr = storageManager.getSequencePropertyBeanMgr();

    String sequenceID = null;

    CreateSequence createSequence = (CreateSequence) rmMsgCtx.getMessagePart(
        Sandesha2Constants.MessageParts.CREATE_SEQ);
View Full Code Here

    MakeConnection makeConnection = (MakeConnection) rmMsgCtx.getMessagePart(Sandesha2Constants.MessageParts.MAKE_CONNECTION);
    Address address = makeConnection.getAddress();
    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.
    int size = collection.size();
    int itemToPick=-1;
   
    boolean pending = false;
    if (size>0) {
      Random random = new Random ();
      itemToPick = random.nextInt(size);
    }

    if (size>1)
      pending = true//there are more than one message to be delivered using the makeConnection.
               //So the MessagePending header should have value true;
   
    Iterator it = collection.iterator();
   
    SenderBean senderBean = null;
    for (int item=0;item<size;item++) {
     
        senderBean = (SenderBean) it.next();
      if (item==itemToPick)
        break;
    }

    if (senderBean==null)
      return false;
     
    TransportOutDescription transportOut = rmMsgCtx.getMessageContext().getTransportOut();
    if (transportOut==null) {
      String message = SandeshaMessageHelper.getMessage(
          SandeshaMessageKeys.cantSendMakeConnectionNoTransportOut);
      throw new SandeshaException (message);
    }
     
    String messageStorageKey = senderBean.getMessageContextRefKey();
    MessageContext returnMessage = storageManager.retrieveMessageContext(messageStorageKey,configurationContext);
    RMMsgContext returnRMMsg = MsgInitializer.initializeMessage(returnMessage);
   
   
    addMessagePendingHeader (returnRMMsg,pending);
   
View Full Code Here

    MessageContext msgCtx = rmMsgCtx.getMessageContext();

    String sequenceId = closeSequence.getIdentifier().getIdentifier();
    String sequencePropertyKey = SandeshaUtil.getSequencePropertyKey(rmMsgCtx);
   
    StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(configCtx, configCtx
        .getAxisConfiguration());
    SequencePropertyBeanMgr sequencePropMgr = storageManager.getSequencePropertyBeanMgr();
   
    // Check that the sender of this CloseSequence holds the correct token
    SequencePropertyBean tokenBean = sequencePropMgr.retrieve(sequenceId, Sandesha2Constants.SequenceProperties.SECURITY_TOKEN);
    if(tokenBean != null) {
      SecurityManager secManager = SandeshaUtil.getSecurityManager(msgCtx.getConfigurationContext());
View Full Code Here

   
    MessageContext msgContext = rmMsgCtx.getMessageContext();
    ConfigurationContext configurationContext = msgContext.getConfigurationContext();
    Options options = msgContext.getOptions();

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

    SequencePropertyBeanMgr seqPropMgr = storageManager.getSequencePropertyBeanMgr();

    String toAddress = rmMsgCtx.getTo().getAddress();
    String sequenceKey = (String) options.getProperty(SandeshaClientConstants.SEQUENCE_KEY);
    String internalSeqenceID = SandeshaUtil.getInternalSequenceID(toAddress, sequenceKey);

    String outSequenceID = SandeshaUtil.getSequenceProperty(internalSeqenceID,
        Sandesha2Constants.SequenceProperties.OUT_SEQUENCE_ID, storageManager);
    if (outSequenceID == null)
      throw new SandeshaException(SandeshaMessageHelper.getMessage(
          SandeshaMessageKeys.couldNotSendCloseSeqNotFound, internalSeqenceID));


    // registring an InOutOperationContext for this.
    // since the serviceContext.fireAndForget only sets a inOnly One
    // this does not work when there is a closeSequnceResponse
    // TODO do processing of closeMessagesCorrectly., create a new
    // message instead of sendign the one given by the serviceClient
    // TODO important

    AxisOperation outInAxisOp = new OutInAxisOperation(new QName("temp"));

    AxisOperation referenceInOutOperation = msgContext.getAxisService()
        .getOperation(
            new QName(Sandesha2Constants.RM_IN_OUT_OPERATION_NAME));
    if (referenceInOutOperation == null) {
      String messge = "Cant find the recerence RM InOut operation";
      throw new SandeshaException(messge);
    }

    outInAxisOp.setParent(msgContext.getAxisService());
    // setting flows
    // outInAxisOp.setRemainingPhasesInFlow(referenceInOutOperation.getRemainingPhasesInFlow());
    outInAxisOp.setRemainingPhasesInFlow(referenceInOutOperation
        .getRemainingPhasesInFlow());

    OperationContext opcontext = OperationContextFactory
        .createOperationContext(
            WSDL20_2004Constants.MEP_CONSTANT_OUT_IN, outInAxisOp);
    opcontext.setParent(msgContext.getServiceContext());
    configurationContext.registerOperationContext(rmMsgCtx.getMessageId(),
        opcontext);

    msgContext.setOperationContext(opcontext);
    msgContext.setAxisOperation(outInAxisOp);
   
    CloseSequence closeSequencePart = (CloseSequence) rmMsgCtx
        .getMessagePart(Sandesha2Constants.MessageParts.CLOSE_SEQUENCE);
    Identifier identifier = closeSequencePart.getIdentifier();
    if (identifier==null) {
      identifier = new Identifier (closeSequencePart.getNamespaceValue());
      closeSequencePart.setIdentifier(identifier);
    }
   
    identifier.setIndentifer(outSequenceID);

    rmMsgCtx.setFlow(MessageContext.OUT_FLOW);
    msgContext.setProperty(Sandesha2Constants.APPLICATION_PROCESSING_DONE, "true");

    rmMsgCtx.setTo(new EndpointReference(toAddress));

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

    rmMsgCtx.setWSAAction(SpecSpecificConstants.getCloseSequenceAction(rmVersion));
    rmMsgCtx.setSOAPAction(SpecSpecificConstants.getCloseSequenceAction (rmVersion));

    String transportTo = SandeshaUtil.getSequenceProperty(internalSeqenceID,
        Sandesha2Constants.SequenceProperties.TRANSPORT_TO, storageManager);
    if (transportTo != null) {
      rmMsgCtx.setProperty(MessageContextConstants.TRANSPORT_URL, transportTo);
    }
   
    //setting msg context properties
    rmMsgCtx.setProperty(Sandesha2Constants.MessageContextProperties.SEQUENCE_ID, outSequenceID);
    rmMsgCtx.setProperty(Sandesha2Constants.MessageContextProperties.INTERNAL_SEQUENCE_ID, internalSeqenceID);
    rmMsgCtx.setProperty(Sandesha2Constants.MessageContextProperties.SEQUENCE_PROPERTY_KEY , sequenceKey);

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

    String key = SandeshaUtil.getUUID();

    SenderBean closeBean = new SenderBean();
    closeBean.setMessageContextRefKey(key);

    storageManager.storeMessageContext(key, msgContext);

    closeBean.setTimeToSend(System.currentTimeMillis());

    closeBean.setMessageID(msgContext.getMessageID());
   
    EndpointReference to = msgContext.getTo();
    if (to!=null)
      closeBean.setToAddress(to.getAddress());
   
    // this will be set to true at the sender.
    closeBean.setSend(true);

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

    if (log.isDebugEnabled())
      log.debug("Enter: FaultManager::processCreateSequenceRefusedFault");

    ConfigurationContext configCtx = rmMsgCtx.getMessageContext().getConfigurationContext();

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

    RelatesTo relatesTo = rmMsgCtx.getMessageContext().getRelatesTo();
    String createSeqMsgId = null;
    if (relatesTo != null) {
      createSeqMsgId = relatesTo.getValue();
    } else {
      // Work out the related message from the operation context
      OperationContext context = rmMsgCtx.getMessageContext().getOperationContext();
      MessageContext createSeq = context.getMessageContext(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
      if(createSeq != null) createSeqMsgId = createSeq.getMessageID();
    }
    if(createSeqMsgId == null) {
      String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.relatesToNotAvailable);
      log.error(message);
      throw new SandeshaException(message);
    }

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

    RMSBean rmsBean = rmsBeanMgr.retrieve(createSeqMsgId);
    if (rmsBean == null) {
      if (log.isDebugEnabled())
        log.debug("Exit: FaultManager::processCreateSequenceRefusedFault Unable to find RMSBean");
View Full Code Here

    if (log.isDebugEnabled())
      log.debug("Enter: FaultManager::processSequenceUnknownFault " + sequenceID);

    ConfigurationContext configCtx = rmMsgCtx.getMessageContext().getConfigurationContext();

    StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(configCtx, configCtx
        .getAxisConfiguration());
   
    // Find the rmsBean
    RMSBean rmsBean = SandeshaUtil.getRMSBeanFromSequenceId(storageManager, sequenceID);
    if (rmsBean != null) {
   
      // Notify the clients of a failure
      notifyClientsOfFault(rmsBean.getInternalSequenceID(), storageManager, configCtx, fault);
     
      rmMsgCtx.pause();
     
      // Cleanup sending side.
      if (log.isDebugEnabled())
        log.debug("Terminating sending sequence " + rmsBean);
      TerminateManager.terminateSendingSide(rmsBean, storageManager);
     
      // Update the last activated time.
      rmsBean.setLastActivatedTime(System.currentTimeMillis());
     
      // Update the bean in the map
      storageManager.getRMSBeanMgr().update(rmsBean);
    }
    else {
      RMDBean rmdBean = SandeshaUtil.getRMDBeanFromSequenceId(storageManager, sequenceID);
      if (rmdBean != null) {
        rmMsgCtx.pause();
       
        // Cleanup sending side.
        if (log.isDebugEnabled())
          log.debug("Terminating sending sequence " + rmdBean);
        TerminateManager.cleanReceivingSideOnTerminateMessage(configCtx, rmdBean.getSequenceID(), storageManager);
       
        // Update the last activated time.
        rmdBean.setLastActivatedTime(System.currentTimeMillis());
       
        // Update the bean in the map
        storageManager.getRMDBeanMgr().update(rmdBean);
     
      }
      else {
        if (log.isDebugEnabled())
          log.debug("Exit: FaultManager::processSequenceUnknownFault Unable to find sequence");
View Full Code Here

      log.debug("Enter: SenderWorker::run");

    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

      if (transaction!=null)
        transaction.commit();
     
      transaction = null;

            if ((processResponseForFaults || successfullySent) && !msgCtx.isServerSide()) {
                boolean  validCs = checkForSyncResponses(msgCtx );
                if (!validCs) {
                    invokeCallBackObject(storageManager,msgCtx ,
                            "Sandesha2 sender thread has not received a valid CreateSequnceResponse");
                }
            }

            if ((rmMsgCtx.getMessageType() == Sandesha2Constants.MessageTypes.TERMINATE_SEQ)
          &&
           (Sandesha2Constants.SPEC_2005_02.NS_URI.equals(rmMsgCtx.getRMNamespaceValue()))) {
        try {
          transaction = storageManager.getTransaction();
          //terminate message sent using the SandeshaClient. Since the terminate message will simply get the
          //InFlow of the reference message get called which could be zero sized (OutOnly operations).
         
          // terminate sending side if this is the WSRM 1.0 spec.
          // If the WSRM versoion is 1.1 termination will happen in the terminate sequence response message.
View Full Code Here

        }
      }

      try {
        ConfigurationContext context = msgCtx.getConfigurationContext();
        StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(context, context.getAxisConfiguration());       
        transaction = storageManager.getTransaction();

        msgProcessor.processInMessage(rmMsgCtx, transaction);

        if(transaction != null && transaction.isActive()) transaction.commit();
          transaction = null;
View Full Code Here

          SandeshaMessageKeys.cannotGetStorageKey));
   
    ConfigurationContext configurationContext = msgContext.getConfigurationContext();
    AxisConfiguration axisConfiguration = configurationContext.getAxisConfiguration();
   
    StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(configurationContext,axisConfiguration);
   
    msgContext.setProperty(Sandesha2Constants.QUALIFIED_FOR_SENDING,Sandesha2Constants.VALUE_TRUE);
   
    storageManager.storeMessageContext(key,msgContext);

    if (log.isDebugEnabled())
      log.debug("Exit: Sandesha2TransportSender::invoke");
    return InvocationResponse.CONTINUE;
  }
View Full Code Here

TOP

Related Classes of org.apache.sandesha2.storage.StorageManager

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.