Examples of SenderBean


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

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

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

   
    return outputStream.toByteArray();
  }
 
  private static SenderBean getSenderBean(String seqID, int sendCount, int messageNo) {
    SenderBean bean = new SenderBean();
    bean.setInternalSequenceID(SandeshaUtil.getInternalSequenceID(seqID, null))
    bean.setSequenceID(seqID);
    bean.setMessageID(SandeshaUtil.getUUID());   
    bean.setSentCount(sendCount);
    bean.setSend(true);
    bean.setReSend(true);
    bean.setMessageType(Sandesha2Constants.MessageTypes.APPLICATION);
    bean.setMessageNumber(messageNo);
   
    return bean;
  }
View Full Code Here

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

    }

    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

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

        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 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

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

//
//        } 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

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

    }

    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

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

        }
        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

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

    // Ensure the outbound message us secured using the correct token
    RMMsgCreator.secureOutboundMessage(getRMSBean(), msgContext);
   
    String key = SandeshaUtil.getUUID();

    SenderBean senderBean = new SenderBean();
    senderBean.setMessageType(msgType);
    senderBean.setMessageContextRefKey(key);
    senderBean.setTimeToSend(System.currentTimeMillis() + delay);
    senderBean.setMessageID(msgContext.getMessageID());
   
    // Set the internal sequence id and outgoing sequence id for the terminate message
    senderBean.setInternalSequenceID(internalSequenceID);
    if (sequenceExists)
    {
      senderBean.setSend(true);
      senderBean.setSequenceID(outSequenceID);
    }
    else
      senderBean.setSend(false);     
   
    EndpointReference to = msgContext.getTo();
    if (to!=null)
      senderBean.setToAddress(to.getAddress());

    // If this message is targetted at an anonymous address then we must not have a transport
    // ready for it, as the current message is not a reply.
    if(to == null || to.hasAnonymousAddress())
      senderBean.setTransportAvailable(false);
   
    msgContext.setProperty(Sandesha2Constants.QUALIFIED_FOR_SENDING, Sandesha2Constants.VALUE_FALSE);

    senderBean.setReSend(false);

    SenderBeanMgr retramsmitterMgr = storageManager.getSenderBeanMgr();
   
    SandeshaUtil.executeAndStore(rmMsgCtx, key);
 
View Full Code Here

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

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

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

    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)
        it.remove();
    }
   
    //selecting a bean to send RANDOMLY. TODO- Should use a better mechanism.
    int size = collection.size();
    int itemToPick=-1;
   
    boolean pending = false;
    if (size>0) {
      Random random = new Random ();
      itemToPick = random.nextInt(size);
    }

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