Package org.apache.sandesha2

Examples of org.apache.sandesha2.RMMsgContext


      if(log.isDebugEnabled())
        log.debug("Exit: TerminateManager::addTerminateSequenceMessage - terminate was added previously.");
      return;
    }

    RMMsgContext terminateRMMessage = RMMsgCreator.createTerminateSequenceMessage(referenceMessage, rmsBean, storageManager);
    terminateRMMessage.setFlow(MessageContext.OUT_FLOW);
    terminateRMMessage.setProperty(Sandesha2Constants.APPLICATION_PROCESSING_DONE, "true");

   
    //setting the To EPR.
    //First try to get it from an Endpoint property.
    //If not get it from the To property.
   
    EndpointReference toEPR = null;
   
    if (rmsBean.getOfferedEndPoint() != null)
      toEPR = new EndpointReference (rmsBean.getOfferedEndPoint());
   
    if (toEPR==null) {

      if (rmsBean.getToEPR()!=null) {
        toEPR = new EndpointReference(rmsBean.getToEPR());
        if (toEPR == null) {
          String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.toEPRNotValid, null);
          throw new SandeshaException(message);
        }
      }
    }

    if (toEPR!=null)
      terminateRMMessage.setTo(toEPR);
   
    if (rmsBean.getReplyToEPR()!=null) {
      terminateRMMessage.setReplyTo(new EndpointReference (rmsBean.getReplyToEPR()));
    }
   
    String rmVersion = rmsBean.getRMVersion();
    terminateRMMessage.setWSAAction(SpecSpecificConstants.getTerminateSequenceAction(rmVersion));
    terminateRMMessage.setSOAPAction(SpecSpecificConstants.getTerminateSequenceSOAPAction(rmVersion));

    if (rmsBean.getTransportTo() != null) {
      terminateRMMessage.setProperty(Constants.Configuration.TRANSPORT_URL, rmsBean.getTransportTo());
    }

    terminateRMMessage.addSOAPEnvelope();

    String key = SandeshaUtil.getUUID();

    SenderBean terminateBean = new SenderBean();
    terminateBean.setInternalSequenceID(internalSequenceID);
    terminateBean.setSequenceID(outSequenceId);
    terminateBean.setMessageContextRefKey(key);
    terminateBean.setMessageType(Sandesha2Constants.MessageTypes.TERMINATE_SEQ);

    // 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.
    terminateBean.setTimeToSend(System.currentTimeMillis() + Sandesha2Constants.TERMINATE_DELAY);

    terminateBean.setMessageID(terminateRMMessage.getMessageId());

    // this will be set to true at the sender.
    terminateBean.setSend(true);

    terminateRMMessage.getMessageContext().setProperty(Sandesha2Constants.QUALIFIED_FOR_SENDING,
        Sandesha2Constants.VALUE_FALSE);

    terminateBean.setReSend(false);
   
    terminateBean.setSequenceID(outSequenceId);
   
    terminateBean.setMessageType(Sandesha2Constants.MessageTypes.TERMINATE_SEQ);
    terminateBean.setInternalSequenceID(internalSequenceID);
   
   
    EndpointReference to = terminateRMMessage.getTo();
    if (to!=null)
      terminateBean.setToAddress(to.getAddress());

    // If this message is targetted at an anonymous address then we must not have a transport
    // ready for it, as the terminate sequence is not a reply.
    if(to == null || to.hasAnonymousAddress())
      terminateBean.setTransportAvailable(false);

    rmsBean.setTerminateAdded(true);

    storageManager.getRMSBeanMgr().update(rmsBean);

    terminateRMMessage.setProperty(Sandesha2Constants.SET_SEND_TO_TRUE, Sandesha2Constants.VALUE_TRUE);
   
    //the propertyKey of the ackMessage will be the propertyKey for the terminate message as well.
//    terminateRMMessage.setProperty(Sandesha2Constants.MessageContextProperties.SEQUENCE_PROPERTY_KEY, sequencePropertyKey);
   
    // / addTerminateSeqTransaction.commit();
View Full Code Here


        log.debug("Exit: TerminateSeqMsgProcessor::processInMessage, unknown sequence");
      return false;
    }

    // add the terminate sequence response if required.
    RMMsgContext terminateSequenceResponse = null;
    if (SpecSpecificConstants.isTerminateSequenceResponseRequired(terminateSeqRMMsg.getRMSpecVersion()))
      terminateSequenceResponse = getTerminateSequenceResponse(terminateSeqRMMsg, rmdBean, sequenceId, storageManager);

    setUpHighestMsgNumbers(context, storageManager, sequenceId, terminateSeqRMMsg);
   
   
   
    boolean inOrderInvocation = SandeshaUtil.getDefaultPropertyBean(context.getAxisConfiguration()).isInOrder();
   
   
    //if the invocation is inOrder and if this is RM 1.1 there is a posibility of all the messages having eleady being invoked.
    //In this case we should do the full termination.
   
    boolean doFullTermination = false;
   
    if (inOrderInvocation) {

      long highestMsgNo = rmdBean.getHighestInMessageNumber();
      long nextMsgToProcess = rmdBean.getNextMsgNoToProcess();
     
      if (nextMsgToProcess>highestMsgNo) {
        //all the messages have been invoked, u can do the full termination
        doFullTermination = true;
      }
    } else {
      //for not-inorder case, always do the full termination.
      doFullTermination = true;
    }
   
    if (doFullTermination) {
      TerminateManager.cleanReceivingSideAfterInvocation(sequenceId, storageManager);
      TerminateManager.cleanReceivingSideOnTerminateMessage(context, sequenceId, storageManager);
    } else
      TerminateManager.cleanReceivingSideOnTerminateMessage(context, sequenceId, storageManager);

    rmdBean.setTerminated(true);   
    rmdBean.setLastActivatedTime(System.currentTimeMillis());
    storageManager.getRMDBeanMgr().update(rmdBean);


    //sending the terminate sequence response
    if (terminateSequenceResponse != null) {
      //
      // As we have processed the input and prepared the response we can commit the
      // transaction now.
      if(transaction != null && transaction.isActive()) transaction.commit();
     
      MessageContext outMessage = terminateSequenceResponse.getMessageContext();
      EndpointReference toEPR = outMessage.getTo();
     
      outMessage.setServerSide(true);
           
      try {             
        AxisEngine.send(outMessage);
      } catch (AxisFault e) {
        if (log.isDebugEnabled())
          log.debug("Unable to send terminate sequence response", e);
       
        throw new SandeshaException(
            SandeshaMessageHelper.getMessage(SandeshaMessageKeys.couldNotSendTerminateResponse), e);
      }
     
      if (toEPR.hasAnonymousAddress()) {
        TransportUtils.setResponseWritten(terminateSeqMsg, true);
      }

    } else {
      //if RM 1.0 Anonymous scenario we will be trying to attache the TerminateSequence of the response side
      //as the response message.
     
      String outgoingSideInternalSeqId = SandeshaUtil.getOutgoingSideInternalSequenceID(sequenceId);
      SenderBean senderFindBean = new SenderBean ();
      senderFindBean.setInternalSequenceID(outgoingSideInternalSeqId);
      senderFindBean.setMessageType(Sandesha2Constants.MessageTypes.TERMINATE_SEQ);
      senderFindBean.setSend(true);
      senderFindBean.setReSend(false);
     
      SenderBean outgoingSideTerminateBean = storageManager.getSenderBeanMgr().findUnique(senderFindBean);
      if (outgoingSideTerminateBean!=null) {
     
        EndpointReference toEPR = new EndpointReference (outgoingSideTerminateBean.getToAddress());
        if (toEPR.hasAnonymousAddress()) {
          String messageKey = outgoingSideTerminateBean
              .getMessageContextRefKey();
          MessageContext message = storageManager
              .retrieveMessageContext(messageKey, context);

          RMMsgContext rmMessage = MsgInitializer.initializeMessage(message);
         
          // attaching the this outgoing terminate message as the
          // response to the incoming terminate message.
          message.setTransportOut(terminateSeqMsg.getTransportOut());
          message.setProperty(MessageContext.TRANSPORT_OUT,terminateSeqMsg.getProperty(MessageContext.TRANSPORT_OUT));
View Full Code Here

      StorageManager storageManager) throws AxisFault {

    if (log.isDebugEnabled())
      log.debug("Enter: TerminateSeqMsgProcessor::addTerminateSequenceResponse, " + sequenceId);

    RMMsgContext terminateSeqResponseRMMsg = RMMsgCreator.createTerminateSeqResponseMsg(terminateSeqRMMsg, rmdBean);
    MessageContext outMessage = terminateSeqResponseRMMsg.getMessageContext();

    RMMsgContext ackRMMessage = AcknowledgementManager.generateAckMessage(terminateSeqRMMsg, rmdBean,
        sequenceId,  storageManager, true);
   
    // copy over the ack parts
    Iterator iter = ackRMMessage.getMessageParts(Sandesha2Constants.MessageParts.SEQ_ACKNOWLEDGEMENT);
    while (iter.hasNext()) {
      SequenceAcknowledgement seqAck = (SequenceAcknowledgement) iter.next();
      terminateSeqResponseRMMsg.setMessagePart(Sandesha2Constants.MessageParts.SEQ_ACKNOWLEDGEMENT, seqAck);
    }
   
View Full Code Here

     
      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<Integer> 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;
      }
     
      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
        AcknowledgementManager.piggybackAcksIfPresent(rmMsgCtx, storageManager);
      }
      if (transaction != null && transaction.isActive())
        transaction.commit();     
     
      transaction = storageManager.getTransaction();

      /*Removing the sending of AckRequested msgs as has performance impact.
        It could be rewritten to send AckRequested headers infrequantly and
        hence be less of a performance impact.  Functionally it
        may be required to interop with other implementations but until
        the problem occurs it's best not to do it at all and keep performance
        as optimal as possible
      //If this is an application msg we need to add an ackRequest to the header   
      if(messageType == Sandesha2Constants.MessageTypes.APPLICATION){       
        //Add an ackRequest       
        RMSBean rmsBean = SandeshaUtil.getRMSBeanFromSequenceId(storageManager, senderBean.getSequenceID());       
        RMMsgCreator.addAckRequest(rmMsgCtx, senderBean.getSequenceID(), rmsBean);               
        if (transaction != null && transaction.isActive())          
          transaction.commit();
       
        transaction = storageManager.getTransaction();     
      } */
     
      //if this is a sync RM exchange protocol we always have to add an ack
      boolean ackPresent = false;
      Iterator it = rmMsgCtx.getSequenceAcknowledgements();
      if (it.hasNext())
        ackPresent = true;
     
      if (!ackPresent && toEPR.hasAnonymousAddress()
          && rmMsgCtx.getMessageContext().isServerSide()
          &&
        (messageType==Sandesha2Constants.MessageTypes.APPLICATION ||
           messageType==Sandesha2Constants.MessageTypes.UNKNOWN ||
           messageType==Sandesha2Constants.MessageTypes.LAST_MESSAGE)) {
       
        String inboundSequenceId = senderBean.getInboundSequenceId();
        if (inboundSequenceId==null)
          throw new SandeshaException ("InboundSequenceID is not set for the sequence:" + senderBean.getSequenceID());
       
        RMDBean incomingSequenceBean = SandeshaUtil.getRMDBeanFromSequenceId(storageManager, inboundSequenceId);

        if (incomingSequenceBean!=null)
          RMMsgCreator.addAckMessage(rmMsgCtx, inboundSequenceId, incomingSequenceBean, false, true);
      }

      if (transaction != null && transaction.isActive())
        transaction.commit();     
     
      transaction = storageManager.getTransaction();
     
      senderBean = updateMessage(rmMsgCtx,senderBean,storageManager);

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

      // Although not actually sent yet, update the send count to indicate an attempt
      if (senderBean.isReSend()) {
        senderBeanMgr.update(senderBean);
      }

      // sending the message
      boolean successfullySent = false;
     
      // No need to redecorate application messages ... only for rm protocol messages
      if(Sandesha2Constants.MessageTypes.APPLICATION!=senderBean.getMessageType()){
        //try to redecorate the EPR if necessary
        if (log.isDebugEnabled())
          log.debug("Redecorate EPR : " + msgCtx.getEnvelope().getHeader());
        EndpointReference replyToEPR = msgCtx.getReplyTo();
        if(replyToEPR!=null){
          replyToEPR = SandeshaUtil.getEPRDecorator(msgCtx.getConfigurationContext()).decorateEndpointReference(replyToEPR);
          msgCtx.setReplyTo(replyToEPR);
        }
      }
      // have to commit the transaction before sending. This may
      // get changed when WS-AT is available.
      if(transaction != null) {
        transaction.commit();
        transaction = null;
      }

      boolean processResponseForFaults = false;
      try {
        InvocationResponse response = InvocationResponse.CONTINUE;
       
        if(storageManager.requiresMessageSerialization()) {
          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 {
 
          ArrayList<Handler> retransmittablePhases = (ArrayList<Handler>) msgCtx.getProperty(Sandesha2Constants.RETRANSMITTABLE_PHASES);
          if (retransmittablePhases!=null) {
            msgCtx.setExecutionChain(retransmittablePhases);
          } else {
            ArrayList<Handler> emptyExecutionChain = new ArrayList<Handler>();
            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());
              msgCtx.setProperty(MessageContext.TRANSPORT_NON_BLOCKING, Boolean.FALSE);
          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.isDebugEnabled())
          log.debug(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);
        } else {
          senderBeanMgr.delete(bean1.getMessageID());

          // removing the message from the storage.
          String messageStoredKey = bean1.getMessageContextRefKey();
          storageManager.removeMessageContext(messageStoredKey);
        }
      }

      // Commit the transaction to release the SenderBean

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

      if ((processResponseForFaults || successfullySent) && !msgCtx.isServerSide())
        checkForSyncResponses(msgCtx);
     
      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.
         
          TerminateSequence terminateSequence = rmMsgCtx.getTerminateSequence();
          String sequenceID = terminateSequence.getIdentifier().getIdentifier();
 
          RMSBean rmsBean = SandeshaUtil.getRMSBeanFromSequenceId(storageManager, sequenceID);
          TerminateManager.terminateSendingSide(rmsBean, storageManager, false, null);
         
View Full Code Here

        }
       
        //we will not be setting the operation context here since this msgs may not be an application reply.
        //we let other dispatchers find it.
        int messageType = MsgInitializer.initializeMessage(responseMessageContext).getMessageType();
        RMMsgContext responseRMMessage = MsgInitializer.initializeMessage(responseMessageContext);
        int responseMessageType = responseRMMessage.getMessageType();
        if(log.isDebugEnabled()) log.debug("inboundMsgType" + responseMessageType + "outgoing message type " + messageType);
                
        //Setting the AxisService object
        responseMessageContext.setAxisService(msgCtx.getAxisService());

        //If addressing is disabled we will be adding this message simply as the application response of the request message.
        Boolean addressingDisabled = (Boolean) msgCtx.getProperty(AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES);
        if (addressingDisabled!=null && Boolean.TRUE.equals(addressingDisabled)) {
          // If the AxisOperation object doesn't have a message receiver, it means that this was
          // an out only op where we have added an ACK to the response.  Set the requestMsgOpCtx to
          // be the RMIn
          OperationContext responseMsgOpCtx = requestMsgOpCtx;
          if (requestMsgOpCtx.getAxisOperation().getMessageReceiver() == null) {
            // Generate a new RM In Only operation

            ServiceContext serviceCtx = msgCtx.getServiceContext();
            AxisOperation op = msgCtx.getAxisService().getOperation(Sandesha2Constants.RM_IN_ONLY_OPERATION);
            responseMsgOpCtx = OperationContextFactory.createOperationContext (op.getAxisSpecificMEPConstant(), op, serviceCtx);         
          }
         
          responseMessageContext.setOperationContext(responseMsgOpCtx);
        }
       
        AxisOperation operation = msgCtx.getAxisOperation();
        if (operation!=null && responseMessageContext.getAxisMessage()==null
            && !(operation instanceof OutOnlyAxisOperation))
          responseMessageContext.setAxisMessage(operation.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE));

        if (responseRMMessage.getMessageType()==Sandesha2Constants.MessageTypes.ACK) {
          responseMessageContext.setAxisOperation(SpecSpecificConstants.getWSRMOperation
              (Sandesha2Constants.MessageTypes.ACK, responseRMMessage.getRMSpecVersion(), responseMessageContext.getAxisService()));
          responseMessageContext.setOperationContext(null);
        }
       
      }
     
View Full Code Here

      log.debug(message);
      throw new AxisFault(message);
    }
   
    // getting rm message
    RMMsgContext rmMsgCtx = MsgInitializer.initializeMessage(msgCtx);

    String DONE = (String) msgCtx
        .getProperty(Sandesha2Constants.APPLICATION_PROCESSING_DONE);
    if (null != DONE && "true".equals(DONE))
      return;

    msgCtx.setProperty(Sandesha2Constants.APPLICATION_PROCESSING_DONE,"true");
   
    String dummyMessageString = (String) msgCtx.getOptions().getProperty(SandeshaClientConstants.DUMMY_MESSAGE);
    boolean dummyMessage = false;
    if (dummyMessageString!=null && Sandesha2Constants.VALUE_TRUE.equals(dummyMessageString))
      dummyMessage = true;
   
    StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(context);

    MsgProcessor msgProcessor = null;
    int messageType = rmMsgCtx.getMessageType();
    if (messageType==Sandesha2Constants.MessageTypes.UNKNOWN) {
      MessageContext requestMsgCtx = msgCtx.getOperationContext().getMessageContext(OperationContextFactory.MESSAGE_LABEL_IN_VALUE);
      if (requestMsgCtx!=null) {  //for the server side
        RMMsgContext reqRMMsgCtx = MsgInitializer.initializeMessage(requestMsgCtx);
        Sequence sequencePart = (Sequence) reqRMMsgCtx.getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);
        if (sequencePart!=null)
          msgProcessor = new ApplicationMsgProcessor ();// a rm intended message.
      } else if (!msgCtx.isServerSide()) //if client side.
          msgProcessor = new ApplicationMsgProcessor ();
    }else  {
View Full Code Here

      String message = "AxisService is null";
      log.debug(message);
      throw new AxisFault(message);
    }

    RMMsgContext rmMsgCtx = null;
    try {
      rmMsgCtx = MsgInitializer.initializeMessage(msgCtx);
    } catch (SandeshaException ex) {
      String message = "Cant initialize the message";
      log.debug(message);
View Full Code Here

public class RMMessageReceiver extends AbstractMessageReceiver {

  public final void receive(MessageContext messgeCtx) throws AxisFault {
    System.out.println("RM MESSSAGE RECEIVER WAS CALLED");
   
    RMMsgContext rmMsgCtx = MsgInitializer.initializeMessage(messgeCtx);
    System.out.println("MsgReceiver got type:" + SandeshaUtil.getMessageTypeString(rmMsgCtx.getMessageType()))
  }
View Full Code Here

    boolean isRMGlobalMessage = SandeshaUtil.isRMGlobalMessage(msgContext);
    if (!isRMGlobalMessage) {
      return;
    }

    RMMsgContext rmMessageContext = MsgInitializer
        .initializeMessage(msgContext);

    //Dropping duplicates
    boolean dropped = dropIfDuplicate(rmMessageContext);
    if (dropped) {
      processDroppedMessage(rmMessageContext);
      return;
    }

        //Persisting the application messages 
//    if (rmMessageContext.getMessageType()==Sandesha2Constants.MessageTypes.APPLICATION) {
//      SandeshaUtil.PersistMessageContext ()
//    }
   
    //Process if global processing possible. - Currently none
    if (SandeshaUtil.isGloballyProcessableMessageType(rmMessageContext
        .getMessageType())) {
      doGlobalProcessing(rmMessageContext);
    }
  }
View Full Code Here

        if (msgCtx == null) {
          log.debug("ERROR: Sender has an Unavailable Message entry");
          break;
        }

        RMMsgContext rmMsgCtx = MsgInitializer.initializeMessage(msgCtx);

        //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()))) {
          continue;
        }
       
        updateMessage(msgCtx);

        Transaction preSendTransaction = storageManager.getTransaction();

        int messageType = rmMsgCtx.getMessageType();
        if (messageType == Sandesha2Constants.MessageTypes.APPLICATION) {
          Sequence sequence = (Sequence) rmMsgCtx.getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);
          String sequenceID = sequence.getIdentifier().getIdentifier();
 
        }
       
        //checking weather this message can carry piggybacked acks
        if (isAckPiggybackableMsgType(messageType) && !isAckAlreadyPiggybacked(rmMsgCtx)) {
          // piggybacking if an ack if available for the same sequence.
          //TODO do piggybacking based on wsa:To
          AcknowledgementManager.piggybackAcksIfPresent(rmMsgCtx);
        }
       
        preSendTransaction.commit();
       
        //sending the message
        TransportOutDescription transportOutDescription = msgCtx.getTransportOut();
        TransportSender transportSender = transportOutDescription.getSender();
         
        boolean successfullySent = false;
        if (transportSender != null) {
          try {
           
            //TODO change this to cater for security.
            transportSender.invoke(msgCtx);
            successfullySent = true;
          } catch (AxisFault e) {
            // TODO Auto-generated catch block
              log.debug("Could not send message");
            log.debug(e.getStackTrace().toString());
          }
        }

        Transaction postSendTransaction = storageManager.getTransaction();

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

        postSendTransaction.commit(); // commiting the current transaction

        if (successfullySent) {
          if (!msgCtx.isServerSide())
            checkForSyncResponses(msgCtx);
        }

        Transaction terminateCleaningTransaction = storageManager.getTransaction();
        if (rmMsgCtx.getMessageType() == Sandesha2Constants.MessageTypes.TERMINATE_SEQ) {
          // terminate sending side.
          TerminateSequence terminateSequence = (TerminateSequence) rmMsgCtx.getMessagePart(Sandesha2Constants.MessageParts.TERMINATE_SEQ);
          String sequenceID = terminateSequence.getIdentifier().getIdentifier();
          ConfigurationContext configContext = msgCtx.getConfigurationContext();
         
          String internalSequenceID = SandeshaUtil.getSequenceProperty(sequenceID,Sandesha2Constants.SequenceProperties.INTERNAL_SEQUENCE_ID,configContext);
          TerminateManager.terminateSendingSide(configContext,internalSequenceID, msgCtx.isServerSide());
View Full Code Here

TOP

Related Classes of org.apache.sandesha2.RMMsgContext

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.