Package org.apache.sandesha2.storage.beans

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


    offerProcessTransaction.commit();
   
    Transaction updateAppMessagesTransaction = storageManager.getTransaction();
   
    SenderBean target = new SenderBean();
    target.setInternalSequenceID(internalSequenceId);
    target.setSend(false);
    target.setReSend(true);

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

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

      //TODO make following exception message more understandable to the user (probably some others exceptions messages as well)
      if (applicationMsg==null)
        throw new SandeshaException ("Unavailable application message");
     
      String rmVersion = SandeshaUtil.getRMVersion(internalSequenceId,configCtx);
      if (rmVersion==null)
        throw new SandeshaException ("Cant find the rmVersion of the given message");
     
      String assumedRMNamespace = SpecSpecificConstants.getRMNamespaceValue(rmVersion);
     
      RMMsgContext applicaionRMMsg = MsgInitializer
          .initializeMessage(applicationMsg);

      Sequence sequencePart = (Sequence) applicaionRMMsg
          .getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);
      if (sequencePart == null) {
        String message = "Sequence part is null";
        log.debug(message);
        throw new SandeshaException(message);
      }
     
      Identifier identifier = new Identifier(factory,assumedRMNamespace);
      identifier.setIndentifer(newOutSequenceId);

      sequencePart.setIdentifier(identifier);

      AckRequested ackRequestedPart = (AckRequested) applicaionRMMsg
          .getMessagePart(Sandesha2Constants.MessageParts.ACK_REQUEST);
      if (ackRequestedPart != null) {
        Identifier id1 = new Identifier(factory,assumedRMNamespace);
        id1.setIndentifer(newOutSequenceId);
        ackRequestedPart.setIdentifier(id1);
      }

      try {
        applicaionRMMsg.addSOAPEnvelope();
      } catch (AxisFault e) {
        throw new SandeshaException(e.getMessage());
      }
     
      //asking to send the application msssage
      tempBean.setSend(true);
      retransmitterMgr.update(tempBean);
     
      //updating the message. this will correct the SOAP envelope string.
      storageManager.updateMessageContext(key,applicationMsg);
    }
View Full Code Here


    StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(configurationContext);

    SenderBeanMgr retransmitterBeanMgr = storageManager.getRetransmitterBeanMgr();
    SequencePropertyBeanMgr sequencePropertyBeanMgr = storageManager.getSequencePropretyBeanMgr();

    SenderBean findBean = new SenderBean();

    String sequnceID = SandeshaUtil.getSequenceIDFromRMMessage (rmMessageContext);

    findBean.setMessageType(Sandesha2Constants.MessageTypes.ACK);
    findBean.setSend(true);
    findBean.setReSend(false);
   
    String carrietTo = rmMessageContext.getTo().getAddress();
   
    Collection collection = retransmitterBeanMgr.find(findBean);
   
    Iterator it = collection.iterator();

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

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

        MessageContext ackMsgContext = storageManager
        .retrieveMessageContext(ackBean.getMessageContextRefKey(),configurationContext);
       
        //wsa:To has to match for piggybacking.
        String to = ackMsgContext.getTo().getAddress();
        if (!carrietTo.equals(to)) {
          continue piggybackLoop;
        }
       
        String ackSequenceID = ackBean.getSequenceID();
       
        //sequenceID has to match for piggybacking
        if (!ackSequenceID.equals(sequnceID)) {
          continue piggybackLoop;
        }
       
        //deleting the ack entry.
        retransmitterBeanMgr.delete(ackBean.getMessageID());

        //Adding the ack to the application message
        RMMsgContext ackRMMsgContext = MsgInitializer.initializeMessage(ackMsgContext);
        if (ackRMMsgContext.getMessageType() != Sandesha2Constants.MessageTypes.ACK) {
          String message = "Invalid ack message entry";
View Full Code Here

      SenderBeanMgr retransmitterBeanMgr = storageManager
          .getRetransmitterBeanMgr();

      String key = SandeshaUtil.getUUID();
     
      SenderBean ackBean = new SenderBean();
      ackBean.setMessageContextRefKey(key);
      ackBean.setMessageID(ackMsgCtx.getMessageID());
      ackBean.setReSend(false);
      ackBean.setSequenceID(sequenceID);
     
      //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);
      long ackInterval = SandeshaUtil.getPropertyBean(referenceMsg.getAxisOperation()).getAcknowledgementInaterval();
     
      //Ack will be sent as stand alone, only after the retransmitter
      // interval.
      long timeToSend = System.currentTimeMillis() + ackInterval;

      //removing old acks.
      SenderBean findBean = new SenderBean();
      findBean.setMessageType(Sandesha2Constants.MessageTypes.ACK);
     
      //this will be set to true in the sandesha2TransportSender.
      findBean.setSend(true);
      findBean.setReSend(false);
      Collection coll = retransmitterBeanMgr.find(findBean);
      Iterator it = coll.iterator();

      if (it.hasNext()) {
        SenderBean oldAckBean = (SenderBean) it.next();
        timeToSend = oldAckBean.getTimeToSend();    //If there is an old ack. This ack will be sent in the old timeToSend.
        retransmitterBeanMgr.delete(oldAckBean.getMessageID());
      }
     
      ackBean.setTimeToSend(timeToSend);
      storageManager.storeMessageContext(key,ackMsgCtx);
     
View Full Code Here

       
        // Get the SenderBeanManager
        SenderBeanMgr senderManager = storageManager.getSenderBeanMgr();
           
        // 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<SenderBean> beans = senderManager.find(senderBean);
        assertTrue("SenderBeans found when the list should be empty", beans.isEmpty());
       
View Full Code Here

    }

    public void testDelete() throws SandeshaStorageException {
        assertNull(mgr.retrieve(""));
        try {
            mgr.insert(new SenderBean("MsgId1", "Key1", false , 1001 , "TmpSeqId1", 1001));
        } catch (Exception ex) {
            fail("should not throw an exception");
        }
        assertNotNull(mgr.retrieve("MsgId1"));
    }
View Full Code Here

        assertNotNull(mgr.retrieve("MsgId1"));
    }

    public void testFind() {
        try {
            mgr.insert(new SenderBean("MsgId2", "Key2", false , 1001 , "TmpSeqId2", 1002));
            mgr.insert(new SenderBean("MsgId3", "Key3", false , 1001 , "TmpSeqId2", 1003));

            SenderBean target = new SenderBean();
            target.setInternalSequenceID("TmpSeqId2");

            Iterator<SenderBean> iterator = mgr.find(target).iterator();
            SenderBean tmp = (SenderBean) iterator.next();

            if (tmp.getMessageID().equals("MsgId2")) {
                tmp = (SenderBean) iterator.next();
                assertTrue(tmp.getMessageID().equals("MsgId3"));
            } else {
                tmp = (SenderBean) iterator.next();
                assertTrue(tmp.getMessageID().equals("MsgId2"));
            }


        } catch (SandeshaException e) {
            fail("should not throw an exception");
View Full Code Here

//
//        } catch (SandeshaException ex) {
//        }

        try {
            mgr.insert(new SenderBean("MsgId4","Key4", false , 1001 , "TmpSeqId4", 1004));
            SenderBean tmp = mgr.retrieve("MsgId4");
            assertTrue(tmp.getMessageContextRefKey().equals("Key4"));


        } catch (SandeshaException e) {
            fail("should not throw an exception");
        }
View Full Code Here

    }

    public void testRetrieve() throws SandeshaStorageException {
        assertNull(mgr.retrieve("MsgId5"));
        try {
            mgr.insert(new SenderBean("MsgId5", "Key5", false , 1001 , "TmpSeqId5", 1005));
        } catch (SandeshaException e) {
            fail("this should not throw an exception");
        }
        assertNotNull(mgr.retrieve("MsgId5"));
    }
View Full Code Here

        }
        assertNotNull(mgr.retrieve("MsgId5"));
    }

    public void testUpdate() throws SandeshaStorageException {
        SenderBean bean = new SenderBean("MsgId6", "Key6", false , 1001 , "TmpSeqId6", 1006);
        try {
            mgr.insert(bean);
        } catch (SandeshaException e) {
            fail("should not throw an exception");
        }
        bean.setSend(true);
        mgr.update(bean);

        SenderBean tmp = mgr.retrieve("MsgId6");
        assertTrue(tmp.isSend());
    }
View Full Code Here

      // missed earlier acks. We also have special processing for sync 2-way when no make connection is
      // in use
      if(replyTo==null || replyTo.isWSAddressingAnonymous()) {

        SenderBeanMgr senderBeanMgr = storageManager.getSenderBeanMgr();
        SenderBean findSenderBean = new SenderBean ();
       
        if (rmMsgCtx.getMessageType()==Sandesha2Constants.MessageTypes.LAST_MESSAGE)
          findSenderBean.setMessageType(Sandesha2Constants.MessageTypes.LAST_MESSAGE);
        else
          findSenderBean.setMessageType(Sandesha2Constants.MessageTypes.APPLICATION);
       
        findSenderBean.setInboundSequenceId(sequence.getIdentifier().getIdentifier());
        findSenderBean.setInboundMessageNumber(sequence.getMessageNumber());
        findSenderBean.setSend(true);
   
        SenderBean replyMessageBean = senderBeanMgr.findUnique(findSenderBean);
         
        // this is effectively a poll for the replyMessage, so re-use the logic in the MakeConnection
        // processor. This will use this thread to re-send the reply, writing it into the transport.
        // As the reply is now written we do not want to continue processing, or suspend, so we abort.
        if(replyMessageBean != null) {
          if(log.isDebugEnabled()) log.debug("Found matching reply for replayed message");
           MakeConnectionProcessor.replyToPoll(rmMsgCtx, replyMessageBean, storageManager, false, null, transaction);
          result = InvocationResponse.ABORT;
          if (log.isDebugEnabled())
            log.debug("Exit: SequenceProcessor::processReliableMessage, replayed message: " + result);
          return result;
        }
      }
     
      EndpointReference acksTo = bean.getAcksToEndpointReference();
     
      //Send an Ack if needed.
      //We are not sending acks for duplicate messages in the anon InOut case.
      //If a standalone ack get sent before the actualy message (I.e. before the original msg get
      //replied), the client may take this as a InOnly message and may avoid looking for the application
      //response if using replay.
      //Therefore we only send acks back in the anon InOnly case.
      int msgExchangePattern = rmMsgCtx.getMessageContext().getAxisOperation().getAxisSpecificMEPConstant();
      if (log.isDebugEnabled())
        log.debug("SequenceProcessor:: mep= " + msgExchangePattern)
      if (WSDLConstants.MEP_CONSTANT_IN_ONLY ==  msgExchangePattern &&
          (replyTo==null || replyTo.getAddress()==null || replyTo.isWSAddressingAnonymous() || replyTo.hasNoneAddress())) {
        sendAckIfNeeded(bean, sequenceId, rmMsgCtx, storageManager, true, acksTo.hasAnonymousAddress())
      }
     
      result = InvocationResponse.ABORT;
      if (log.isDebugEnabled())
        log.debug("Exit: SequenceProcessor::processReliableMessage, dropping duplicate: " + result);
      return result;
    }
   
    // If the message is a reply to an outbound message then we can update the RMSBean that
    // matches.
    EndpointReference toEPR = msgCtx.getTo();
    if(toEPR == null || toEPR.hasAnonymousAddress()) {
      RMSBean outBean = null;
      // Look for the correct outbound sequence by checking the anon uuid (if there is one)
      String toAddress = (toEPR == null) ? null : toEPR.getAddress();
      if(SandeshaUtil.isWSRMAnonymous(toAddress)) {
        RMSBean finderBean = new RMSBean();
        finderBean.setAnonymousUUID(toAddress);
        outBean = storageManager.getRMSBeanMgr().findUnique(finderBean);
      }
     
      // Fall back to the sequence that may have been offered at sequence creation time
      if(outBean == null) {
        String outboundSequence = bean.getOutboundInternalSequence();
        if(outboundSequence != null) {
          outBean = SandeshaUtil.getRMSBeanFromInternalSequenceId(storageManager, outboundSequence);
        }
      }
     
      // Update the reply count
      if(outBean != null && outBean.getExpectedReplies() > 0 ) {
        outBean.setExpectedReplies(outBean.getExpectedReplies() - 1);
        RMSBeanMgr outMgr = storageManager.getRMSBeanMgr();
        outMgr.update(outBean);
      }
    }
   
    // Set the last activated time
    bean.setLastActivatedTime(System.currentTimeMillis());
   
    // Update the RMD bean
    mgr.update(bean);
   
    // If we are doing sync 2-way over WSRM 1.0, then we may just have received one of
    // the reply messages that we were looking for. If so we can remove the matching sender bean.
    int mep = msgCtx.getAxisOperation().getAxisSpecificMEPConstant();
    if(specVersion!=null && specVersion.equals(Sandesha2Constants.SPEC_VERSIONS.v1_0) &&
        mep == WSDLConstants.MEP_CONSTANT_OUT_IN) {
      RelatesTo relatesTo = msgCtx.getRelatesTo();
      if(relatesTo != null) {
        String messageId = relatesTo.getValue();
        SenderBean sender = storageManager.getSenderBeanMgr().retrieve(messageId);
        if(sender != null) {
          if(log.isDebugEnabled()) log.debug("Deleting sender for sync-2-way message");
         
          storageManager.removeMessageContext(sender.getMessageContextRefKey());
         
          //this causes the request to be deleted even without an ack.
          storageManager.getSenderBeanMgr().delete(messageId);
         
          // Try and terminate the corresponding outbound sequence
          RMSBean rmsBean = SandeshaUtil.getRMSBeanFromSequenceId(storageManager, sender.getSequenceID());
          TerminateManager.checkAndTerminate(rmMsgCtx.getConfigurationContext(), storageManager, rmsBean);
        }
      }
    }
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.