Examples of SenderBeanMgr


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

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

    senderBean.setReSend(false);

    SenderBeanMgr retramsmitterMgr = storageManager.getSenderBeanMgr();
   
    SandeshaUtil.executeAndStore(rmMsgCtx, key);
 
    retramsmitterMgr.insert(senderBean);
   
    if (log.isDebugEnabled())
      log.debug("Exit: WSRMParentProcessor::sendOutgoingMessage");

  }
View Full Code Here

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

    } else {
      //If AcksTo is non-anonymous we will be adding a senderBean entry here. The sender is responsible
      //for sending it out.
     
      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());
     
      //acks are sent only once.
      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);
      SandeshaPolicyBean propertyBean = SandeshaUtil.getPropertyBean(msgContext.getAxisMessage());

      long ackInterval = propertyBean.getAcknowledgementInterval();

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

      // removing old acks.
      SenderBean findBean = new SenderBean();
      findBean.setMessageType(Sandesha2Constants.MessageTypes.ACK);
      Collection coll = senderBeanMgr.find(findBean);
      Iterator it = coll.iterator();

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

      ackBean.setTimeToSend(timeToSend);

      msgContext.setProperty(Sandesha2Constants.QUALIFIED_FOR_SENDING, Sandesha2Constants.VALUE_FALSE);
     
      // passing the message through sandesha2sender
      SandeshaUtil.executeAndStore(ackRMMsgCtx, key);

      // inserting the new Ack.
      senderBeanMgr.insert(ackBean);

      msgContext.pause();

      if (log.isDebugEnabled())
        log.debug("Exit: AckRequestedProcessor::processAckRequestedHeader " + Boolean.TRUE);
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);
    findSenderBean.setTransportAvailable(false);
   
    if (address!=null)
      findSenderBean.setToAddress(address.getAddress());
   
    if (identifier!=null)
      findSenderBean.setSequenceID(identifier.getIdentifier());
   
    // Set the time to send field to be now
    findSenderBean.setTimeToSend(System.currentTimeMillis());
   
    //finding the beans that go with the criteria of the passed SenderBean
    //The reSend flag is ignored for this selection, so there is no need to
    //set it.
    Collection collection = senderBeanMgr.find(findSenderBean);
   
    //removing beans that does not pass the resend test
    for (Iterator it=collection.iterator();it.hasNext();) {
      SenderBean bean = (SenderBean) it.next();
      if (!bean.isReSend() && bean.getSentCount()>0)
View Full Code Here

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

  public static Transaction piggybackAcksIfPresent(RMMsgContext rmMessageContext, StorageManager storageManager, Transaction transaction)
      throws SandeshaException {
    if (log.isDebugEnabled())
      log.debug("Enter: AcknowledgementManager::piggybackAcksIfPresent");
   
    SenderBeanMgr retransmitterBeanMgr = storageManager.getSenderBeanMgr();

    // If this message is going to an anonymous address, and the inbound sequence has
    // anonymous acksTo, then we add in an ack for the inbound sequence.
    EndpointReference target = rmMessageContext.getTo();
    if(target == null || target.hasAnonymousAddress()) {
      if(target != null && SandeshaUtil.isWSRMAnonymous(target.getAddress())) {
        // Search for any sequences that have an acksTo that matches this target, and add an ack
        // for each of them.
        RMDBean findBean = new RMDBean();
        findBean.setAcksToEPR(target.getAddress());
        findBean.setTerminated(false);
        Collection rmdBeans = storageManager.getRMDBeanMgr().find(findBean);
        Iterator sequences = rmdBeans.iterator();
        while(sequences.hasNext()) {
          RMDBean sequence = (RMDBean) sequences.next();
          if (sequence.getHighestInMessageNumber() > 0) {
            if(log.isDebugEnabled()) log.debug("Piggybacking ack for sequence: " + sequence.getSequenceID());
            RMMsgCreator.addAckMessage(rmMessageContext, sequence.getSequenceID(), sequence);
          }
        }
       
      } else {
        // We have no good indicator of the identity of the destination, so the only sequence
        // we can ack is the inbound one that caused us to create this response.
        String inboundSequence = (String) rmMessageContext.getProperty(Sandesha2Constants.MessageContextProperties.INBOUND_SEQUENCE_ID);
        if(inboundSequence != null) {
          RMDBean inboundBean = SandeshaUtil.getRMDBeanFromSequenceId(storageManager, inboundSequence);
          if(inboundBean != null && !inboundBean.isTerminated()) {
            String acksTo = inboundBean.getAcksToEPR();
            EndpointReference acksToEPR = new EndpointReference(acksTo);
           
            if(acksTo == null || acksToEPR.hasAnonymousAddress()) {
              if(log.isDebugEnabled()) log.debug("Piggybacking ack for inbound sequence: " + inboundSequence);
              RMMsgCreator.addAckMessage(rmMessageContext, inboundSequence, inboundBean);
            }
          }
        }
      }
      if(log.isDebugEnabled()) log.debug("Exit: AcknowledgementManager::piggybackAcksIfPresent, anon");
      return transaction;
    }
   
    // From here on, we must be dealing with a real address. Piggyback all sequences that have an
    // acksTo that matches the To address, and that have an ackMessage queued up for sending.
    Set acked = new HashSet();
    SenderBean findBean = new SenderBean();
    findBean.setMessageType(Sandesha2Constants.MessageTypes.ACK);
    findBean.setSend(true);
    findBean.setToAddress(target.getAddress());

    Collection collection = retransmitterBeanMgr.find(findBean);
   
    if (transaction != null && transaction.isActive())
      transaction.commit();
   
    transaction = storageManager.getTransaction();
   
    Iterator it = collection.iterator();
    while (it.hasNext()) {
      SenderBean ackBean = (SenderBean) it.next();

      // Piggybacking will happen only if the end of ack interval (timeToSend) is not reached.
      long timeNow = System.currentTimeMillis();
      if (ackBean.getTimeToSend() > timeNow) {
        // Delete the beans that would have sent the ack
        retransmitterBeanMgr.delete(ackBean.getMessageID());
        storageManager.removeMessageContext(ackBean.getMessageContextRefKey());

        String sequenceId = ackBean.getSequenceID();
        if (log.isDebugEnabled()) log.debug("Piggybacking ack for sequence: " + sequenceId);
View Full Code Here

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

    // Write the acks into the envelope
    ackRMMsgContext.addSOAPEnvelope();
   
    MessageContext ackMsgContext = ackRMMsgContext.getMessageContext();

    SenderBeanMgr retransmitterBeanMgr = storageManager.getSenderBeanMgr();

    String key = SandeshaUtil.getUUID();

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

    ackBean.setSend(true);
    ackMsgContext.setProperty(Sandesha2Constants.QUALIFIED_FOR_SENDING, Sandesha2Constants.VALUE_FALSE);

    ackBean.setMessageType(Sandesha2Constants.MessageTypes.ACK);

    // removing old acks.
    SenderBean findBean = new SenderBean();
    findBean.setMessageType(Sandesha2Constants.MessageTypes.ACK);
    findBean.setSend(true);
    findBean.setReSend(false);
    findBean.setSequenceID(sequenceId);
    Collection coll = retransmitterBeanMgr.find(findBean);
    Iterator it = coll.iterator();

    while(it.hasNext()) {
      SenderBean oldAckBean = (SenderBean) it.next();
      if(oldAckBean.getTimeToSend() < timeToSend)
        timeToSend = oldAckBean.getTimeToSend();

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

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

    ackBean.setTimeToSend(timeToSend);

    ackMsgContext.setProperty(Sandesha2Constants.QUALIFIED_FOR_SENDING, Sandesha2Constants.VALUE_FALSE);
   
    // passing the message through sandesha2sender
    ackMsgContext.setProperty(Sandesha2Constants.SET_SEND_TO_TRUE, Sandesha2Constants.VALUE_TRUE);
   
    SandeshaUtil.executeAndStore(ackRMMsgContext, key);

    // inserting the new ack.
    retransmitterBeanMgr.insert(ackBean);

    if(log.isDebugEnabled()) log.debug("Exit: AcknowledgementManager::addAckBeanEntry");
  }
View Full Code Here

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

       
        // Get the sequence id for this sequence.
        String sequenceId = SandeshaClient.getSequenceID(serviceClient);
       
        // Get the SenderBeanManager
        SenderBeanMgr senderManager = storageManager.getSenderBeanMgr();
           
        Transaction transaction = storageManager.getTransaction();
       
        // Check that there are no sender beans inside the SenderBeanMgr.
        SenderBean senderBean = new SenderBean();
        senderBean.setSequenceID(sequenceId);
        senderBean.setSend(true);
        senderBean.setReSend(false);
       
        // Find any sender beans for the to address.
        List beans = senderManager.find(senderBean);
       
        //only the ackRequested bean will be present.
        assertTrue("SenderBeans found when the list should be empty", (beans.size()==1));
       
        SequenceReport sequenceReport = SandeshaClient.getOutgoingSequenceReport(serviceClient);
View Full Code Here

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

    // Create an RMS on the service.
    StorageManager storageManager =
      SandeshaUtil.getSandeshaStorageManager(serverConfigContext, serverConfigContext.getAxisConfiguration());
   
    RMSBeanMgr rmsBeanMgr = storageManager.getRMSBeanMgr();
    SenderBeanMgr senderMgr = storageManager.getSenderBeanMgr();
   
    String seqID = SandeshaUtil.getUUID();
   
    // Mockup an RMSBean
    RMSBean rmsBean = new RMSBean();
    rmsBean.setCreateSeqMsgID(SandeshaUtil.getUUID());
    rmsBean.setSequenceID(seqID);
    rmsBean.setInternalSequenceID(SandeshaUtil.getInternalSequenceID(seqID, null));
    rmsBean.setToEPR(AddressingConstants.Final.WSA_ANONYMOUS_URL);
    rmsBean.setAcksToEPR(AddressingConstants.Final.WSA_ANONYMOUS_URL);
    rmsBean.setReplyToEPR(AddressingConstants.Final.WSA_ANONYMOUS_URL);
    rmsBean.setRMVersion(Sandesha2Constants.SPEC_VERSIONS.v1_1);
    rmsBean.setClientCompletedMessages(new RangeString());
    rmsBean.setNextMessageNumber(4);
    rmsBean.setHighestOutMessageNumber(3);
   
    SenderBean bean1 = getSenderBean(seqID, 1, 1);
    SenderBean bean2 = getSenderBean(seqID, 0, 2);
    SenderBean bean3 = getSenderBean(seqID, 1, 3);   

    // Create a transaction and insert the RMSBean
    Transaction tran = storageManager.getTransaction();
   
    rmsBeanMgr.insert(rmsBean);
    senderMgr.insert(bean1);
    senderMgr.insert(bean2);
    senderMgr.insert(bean3);   
   
    tran.commit();
   
    // Open a connection to the endpoint, using the sequence ack as the action
    HttpURLConnection connection =
View Full Code Here

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

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

    SenderBeanMgr retransmitterMgr = storageManager.getSenderBeanMgr();

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

      rmsBean.setOfferedSequence(offeredSequenceId);
    }

    MessageContext createSeqMsg = createSeqRMMessage.getMessageContext();
    createSeqMsg.setRelationships(null); // create seq msg does not
                        // relateTo anything
   
    String createSequenceMessageStoreKey = SandeshaUtil.getUUID(); // the key that will be used to store
                                     //the create sequence message.
   
    rmsBean.setCreateSeqMsgID(createSeqMsg.getMessageID());
    rmsBean.setCreateSequenceMsgStoreKey(createSequenceMessageStoreKey);
   
    //cloning the message and storing it as a reference.
    MessageContext clonedMessage = SandeshaUtil.cloneMessageContext(createSeqMsg);
    String clonedMsgStoreKey = SandeshaUtil.getUUID();
    storageManager.storeMessageContext(clonedMsgStoreKey, clonedMessage);
    rmsBean.setReferenceMessageStoreKey(clonedMsgStoreKey);
   
    SecurityToken token = (SecurityToken) createSeqRMMessage.getProperty(Sandesha2Constants.MessageContextProperties.SECURITY_TOKEN);
    if(token != null) {
      SecurityManager secManager = SandeshaUtil.getSecurityManager(configCtx);
      rmsBean.setSecurityTokenData(secManager.getTokenRecoveryData(token));
    }
   
    storageManager.getRMSBeanMgr().insert(rmsBean);

    SenderBean createSeqEntry = new SenderBean();
    createSeqEntry.setMessageContextRefKey(createSequenceMessageStoreKey);
    createSeqEntry.setTimeToSend(System.currentTimeMillis());
    createSeqEntry.setMessageID(createSeqRMMessage.getMessageId());
    createSeqEntry.setInternalSequenceID(rmsBean.getInternalSequenceID());
    // this will be set to true in the sender
    createSeqEntry.setSend(true);
    // Indicate that this message is a create sequence
    createSeqEntry.setMessageType(Sandesha2Constants.MessageTypes.CREATE_SEQ);
    EndpointReference to = createSeqRMMessage.getTo();
    if (to!=null)
      createSeqEntry.setToAddress(to.getAddress());
    // If this message is targetted at an anonymous address then we must not have a transport
    // ready for it, as the create sequence is not a reply.
    if(to == null || to.hasAnonymousAddress())
      createSeqEntry.setTransportAvailable(false);

    createSeqMsg.setProperty(Sandesha2Constants.QUALIFIED_FOR_SENDING, Sandesha2Constants.VALUE_FALSE);
   
    SandeshaUtil.executeAndStore(createSeqRMMessage, createSequenceMessageStoreKey);

    retransmitterMgr.insert(createSeqEntry);

    // Setup enough of the workers to get this create sequence off the box.
    SandeshaUtil.startWorkersForSequence(configCtx, rmsBean);
   
    if (log.isDebugEnabled())
View Full Code Here

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

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

    MessageContext msg = rmMsg.getMessageContext();

    SenderBeanMgr retransmitterMgr = storageManager.getSenderBeanMgr();

    // setting last message
    boolean lastMessage = false;
    if (msg.isServerSide()) {
      Boolean inboundLast = (Boolean) msg.getProperty(Sandesha2Constants.MessageContextProperties.INBOUND_LAST_MESSAGE);
      if (inboundLast != null && inboundLast.booleanValue()) {
        lastMessage = true;
      }

    } else {
      // client side
      Object obj = msg.getProperty(SandeshaClientConstants.LAST_MESSAGE);
      if (obj != null && "true".equals(obj)) {
        lastMessage = true;
      }
    }

    // Now that we have decided which sequence to use for the message, make sure that we secure
    // it with the correct token.
    RMMsgCreator.secureOutboundMessage(rmsBean, msg);

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

    appMsgEntry.setMessageContextRefKey(storageKey);

    appMsgEntry.setTimeToSend(System.currentTimeMillis());
    appMsgEntry.setMessageID(rmMsg.getMessageId());
    appMsgEntry.setMessageNumber(messageNumber);
    appMsgEntry.setLastMessage(lastMessage);
   
    SOAPEnvelope envelope = rmMsg.getSOAPEnvelope();
    if (lastMessage && envelope!=null && envelope.getBody().getFirstOMChild()==null)
      appMsgEntry.setMessageType(Sandesha2Constants.MessageTypes.LAST_MESSAGE);
    else
      appMsgEntry.setMessageType(Sandesha2Constants.MessageTypes.APPLICATION);
   
    appMsgEntry.setInboundSequenceId(inboundSequence);
    appMsgEntry.setInboundMessageNumber(inboundMessageNumber);
    if (outSequenceID == null) {
      appMsgEntry.setSend(false);
    } else {
      appMsgEntry.setSend(true);
      // Send will be set to true at the sender.
      msg.setProperty(Sandesha2Constants.SET_SEND_TO_TRUE, Sandesha2Constants.VALUE_TRUE);
      appMsgEntry.setSequenceID(outSequenceID);
    }
   
    EndpointReference to = rmMsg.getTo();
    if (to!=null)
      appMsgEntry.setToAddress(to.getAddress());
   
    appMsgEntry.setInternalSequenceID(internalSequenceId);

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

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

    SandeshaUtil.executeAndStore(rmMsg, storageKey);

    retransmitterMgr.insert(appMsgEntry);

    if (log.isDebugEnabled())
      log.debug("Exit: ApplicationMsgProcessor::processResponseMessage");
  }
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
          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");
        return;
      }

      if (msgCtx == null) {
        if (log.isDebugEnabled())
          log.debug(SandeshaMessageHelper.getMessage(SandeshaMessageKeys.sendHasUnavailableMsgEntry));
        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());
        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;
      }
     
      boolean continueSending = updateMessage(rmMsgCtx,senderBean,storageManager);

      if (!continueSending) {
        if (log.isDebugEnabled())
          log.debug("Exit: SenderWorker::run, !continueSending");
        return;
      }

      int messageType = senderBean.getMessageType();
     
      if (isAckPiggybackableMsgType(messageType)) {
        // Piggyback ack messages based on the 'To' address of the message
        AcknowledgementManager.piggybackAcksIfPresent(rmMsgCtx, storageManager);
      }

      // 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);
     
      try {
        AxisEngine engine = new AxisEngine (msgCtx.getConfigurationContext());
        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 = engine.resumeSend(msgCtx);
          } else {
            if (log.isDebugEnabled())
              log.debug("Sending a message : " + msgCtx.getEnvelope().getHeader());
            msgCtx.setProperty(MessageContext.TRANSPORT_NON_BLOCKING, Boolean.FALSE);
            engine.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 = engine.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 (Exception e) {
        String message = SandeshaMessageHelper.getMessage(
            SandeshaMessageKeys.sendMsgError, e.toString());
       
        if (log.isErrorEnabled())
          log.error(message, e);
        // Store the Exception as a sequence property to enable the client to lookup the last
        // exception time and timestamp.
       
        try
        {
          // Create a new Transaction
          transaction = storageManager.getTransaction();
         
          // Get the internal sequence id from the context
          String internalSequenceId = (String)rmMsgCtx.getProperty(Sandesha2Constants.MessageContextProperties.INTERNAL_SEQUENCE_ID);
         
          RMSBean bean = SandeshaUtil.getRMSBeanFromInternalSequenceId(storageManager, internalSequenceId);
         
          if (bean != null) {           
            bean.setLastSendError(e);
            bean.setLastSendErrorTimestamp(System.currentTimeMillis());
          }
         
          // Update the RMSBean
          storageManager.getRMSBeanMgr().update(bean);
         
          // Commit the properties
          if(transaction != null) {
            transaction.commit();
            transaction = null;
          }
        }
        catch (Exception e1)
        {
          if (log.isErrorEnabled())
            log.error(e1);
        } finally {
          if (transaction != null) {
            transaction.rollback();
            transaction = null;
          }
        }
       
      }
      // 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);
        }
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.