Package org.apache.sandesha2.storage.beans

Examples of org.apache.sandesha2.storage.beans.SenderBean


         (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


      makeConnectionRMMessage.setProperty(MessageContext.TRANSPORT_IN,null);
      //storing the MakeConnection message.
      String makeConnectionMsgStoreKey = SandeshaUtil.getUUID();
     
      //add an entry for the MakeConnection message to the sender (with ,send=true, resend=false)
      SenderBean makeConnectionSenderBean = new SenderBean ();
      makeConnectionSenderBean.setInternalSequenceID(internalSeqId);
      makeConnectionSenderBean.setMessageContextRefKey(makeConnectionMsgStoreKey);
      makeConnectionSenderBean.setMessageID(makeConnectionRMMessage.getMessageId());
      makeConnectionSenderBean.setMessageType(Sandesha2Constants.MessageTypes.MAKE_CONNECTION_MSG);
      makeConnectionSenderBean.setReSend(false);
      makeConnectionSenderBean.setSend(true);
      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);
View Full Code Here

       
        return false;
      }
     
      SenderBeanMgr mgr = storageManager.getSenderBeanMgr();
      SenderBean senderBean = mgr.getNextMsgToSend(sequenceId);
     
     
     
      if (senderBean == null ||
          (!senderBean.isReSend() && senderBean.getSentCount()>0)) {
       
        //We will be not proceeding if
        //senderBean is Null
        //OR
        //Sender bean is not valid for re-sending.
       
        if (log.isDebugEnabled()) log.debug("Exit: Sender::internalRun, no message for this sequence");
       
        if(transaction != null && transaction.isActive()) {
          transaction.commit();
          transaction = null;
        }
       
        return false; // Move on to the next sequence in the list
      }

      // work Id is used to define the piece of work that will be
      // assigned to the Worker thread,
      // to handle this Sender bean.
     
      //workId contains a timeTiSend part to cater for retransmissions.
      //This will cause retransmissions to be treated as new work.
      String workId = senderBean.getMessageID() + senderBean.getTimeToSend();

      // check weather the bean is already assigned to a worker.
      if (getWorkerLock().isWorkPresent(workId)) {
        // As there is already a worker running we are probably looping
        // too fast, so sleep on the next loop.
View Full Code Here

      transaction = manager.getTransaction();
     
      // This finder will look for beans that have been locking the transport for longer than
      // the TRANSPORT_WAIT_TIME. The match method for SenderBeans does the time comparison
      // for us.
      SenderBean finder = new SenderBean();
      finder.setSend(false);
      finder.setTransportAvailable(true);
      finder.setTimeToSend(System.currentTimeMillis() - Sandesha2Constants.TRANSPORT_WAIT_TIME);
     
      List beans = manager.getSenderBeanMgr().find(finder);
      Iterator beanIter = beans.iterator();
      while(beanIter.hasNext()) {
        // The beans we have found are assigned to an internal sequence id, but the create
        // sequence has not completed yet (and perhaps never will). Server-side, most of the
        // info that we can usefully print is associated with the inbound sequence that generated
        // this message.
        SenderBean bean = (SenderBean) beanIter.next();
       
        // Load the message, so that we can free the transport (if there is one there). The
        // case we are trying to free up is when there is a request-response transport, and
        // it's still there waiting.
        MessageContext msgCtx = manager.retrieveMessageContext(bean.getMessageContextRefKey(), context);

        RequestResponseTransport t = null;
        MessageContext inMsg = null;
        OperationContext op = msgCtx.getOperationContext();
        if (op != null)
          inMsg = op.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
        if (inMsg != null)
          t = (RequestResponseTransport) inMsg.getProperty(RequestResponseTransport.TRANSPORT_CONTROL);
 
        if((t != null && !RequestResponseTransportStatus.WAITING.equals(t.getStatus()))) {
          if(log.isWarnEnabled()) {
            String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.freeingTransport);
            log.warn(message);
          }
          // If the message is a reply, then the request may need to be acked. Rather
          // than just return a HTTP 202, we should try to send an ack.
          boolean sendAck = false;
          RMDBean inbound = null;
          String inboundSeq = bean.getInboundSequenceId();
          if(inboundSeq != null)
            inbound = SandeshaUtil.getRMDBeanFromSequenceId(manager, inboundSeq);
         
          if(inbound != null) {
            String acksTo = inbound.getAcksToEPR();
            EndpointReference acksToEPR = new EndpointReference(acksTo);
            if(acksTo == null || acksToEPR.hasAnonymousAddress())
              sendAck = true;
          }
         
          if(sendAck) {
            RMMsgContext rmMsgCtx = MsgInitializer.initializeMessage(msgCtx);
            RMMsgContext ackRMMsgCtx = AcknowledgementManager.generateAckMessage(
                rmMsgCtx, inbound, inbound.getSequenceID(), storageManager, true);
            AcknowledgementManager.sendAckNow(ackRMMsgCtx);
            TransportUtils.setResponseWritten(msgCtx, true);
          } else {
            TransportUtils.setResponseWritten(msgCtx, false);
          }
 
          // Mark the bean so that we know the transport is missing, and reset the send time
          bean.setTransportAvailable(false);
          bean.setTimeToSend(System.currentTimeMillis());
         
          // Update the bean
          manager.getSenderBeanMgr().update(bean);
        }
      }
View Full Code Here

      tran = manager.getTransaction();
 
      // This finder will look for beans that should have been sent, but could not be sent
      // because they need a MakeConnection message to come in to pick it up. We also factor
      // in TRANSPORT_WAIT_TIME to give the MakeConnection a chance to arrive.
      SenderBean finder = new SenderBean();
      finder.setSend(true);
      finder.setTransportAvailable(false);
      finder.setTimeToSend(System.currentTimeMillis() - Sandesha2Constants.TRANSPORT_WAIT_TIME);
     
      List beans = manager.getSenderBeanMgr().find(finder);
      Iterator beanIter = beans.iterator();
      while(beanIter.hasNext()) {
        SenderBean bean = (SenderBean) beanIter.next();
       
        // Emit a message to warn the user that MakeConnections are not arriving to pick
        // messages up
        if(log.isWarnEnabled()) {
          String messageType = Integer.toString(bean.getMessageType());
          String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.noPolling, messageType);
          log.warn(message);
        }
       
        // Update the bean so that we won't emit another message for another TRANSPORT_WAIT_TIME
        bean.setTimeToSend(System.currentTimeMillis());
        manager.getSenderBeanMgr().update(bean);
      }
 
      if(tran != null && tran.isActive()) tran.commit();
      tran = null;
View Full Code Here

          SandeshaMessageKeys.nullMsgId));
   
    //checking weather there are any conflicting entries in the current table.
    List findBeanList = new ArrayList ();
   
    SenderBean findBean = new SenderBean ();
    if (bean.getMessageID()!=null) {
      findBean.setMessageID (bean.getMessageID());
      findBeanList.add(findBean);
    }
   
    checkKeys (findBeanList);
   
View Full Code Here

    mgr.getInMemoryTransaction().setSentMessages(true);
    return result;
  }

  public List find(String internalSequenceID) throws SandeshaStorageException {
    SenderBean temp = new SenderBean();
    temp.setInternalSequenceID(internalSequenceID);
    return super.find(temp);
  }
View Full Code Here

  public SenderBean getNextMsgToSend(String sequenceId) throws SandeshaStorageException {
    if(log.isDebugEnabled()) log.debug("Entry: InMemorySenderBeanManager::getNextMessageToSend " + sequenceId);
   
    // Set up match criteria
    SenderBean matcher = new SenderBean();
    matcher.setSend(true);
    matcher.setSequenceID(sequenceId);
    matcher.setTimeToSend(System.currentTimeMillis());
    matcher.setTransportAvailable(true);
   
    List matches = super.find(matcher);
    if(log.isDebugEnabled()) log.debug("Found " + matches.size() + " messages");
   
    // Look for the message with the lowest send time, and send that one.
    SenderBean result = null;
    Iterator i = matches.iterator();
    while(i.hasNext()) {
      SenderBean bean = (SenderBean) i.next();
      if (bean.getTimeToSend()<0)
        continue; //Beans with negative timeToSend values are not considered as candidates for sending.
     
      if (bean.getSentCount() > 0 && !bean.isReSend())
        continue; //Avoid re-sending messages that we should not resend
     
      // Check that the Send time has not been updated under another thread
      if (!bean.match(matcher))
        continue;
     
      if(result == null) {
        result = bean;
      } else if(result.getTimeToSend() > bean.getTimeToSend()) {
        result = bean;
      }
    }
   
    if(log.isDebugEnabled()) log.debug("Exit: InMemorySenderBeanManager::getNextMessageToSend " + result);
View Full Code Here

      if (log.isDebugEnabled())
        log.debug("Exit: FaultManager::processCreateSequenceRefusedFault Allowing another CreateSequence attempt");
      return;
    }
*/
    SenderBean createSequenceSenderBean = retransmitterMgr.retrieve(createSeqMsgId);
    if (createSequenceSenderBean == null)
      throw new SandeshaException(SandeshaMessageHelper.getMessage(SandeshaMessageKeys.createSeqEntryNotFound));

    // deleting the create sequence entry.
    retransmitterMgr.delete(createSeqMsgId);
View Full Code Here

  static void notifyClientsOfFault(String internalSequenceId,
      StorageManager storageManager, ConfigurationContext configCtx, AxisFault fault) throws SandeshaStorageException {
    // Locate and update all of the messages for this sequence, now that we know
    // the sequence id.
    SenderBean target = new SenderBean();
    target.setInternalSequenceID(internalSequenceId);
   
    Iterator iterator = storageManager.getSenderBeanMgr().find(target).iterator();
    while (iterator.hasNext()) {
      SenderBean tempBean = (SenderBean) iterator.next();

      String messageStoreKey = tempBean.getMessageContextRefKey();
     
      // Retrieve the message context.
      MessageContext context = storageManager.retrieveMessageContext(messageStoreKey, configCtx);
     
      AxisOperation axisOperation = context.getAxisOperation();
View Full Code Here

TOP

Related Classes of org.apache.sandesha2.storage.beans.SenderBean

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.