Examples of MsgQosData


Examples of org.xmlBlaster.util.qos.MsgQosData

            log.severe("Can't find JdbcDriver instance");
            Thread.currentThread().dumpStack();
            throw new XmlBlasterException(glob, ErrorCode.INTERNAL_UNKNOWN, ME, "Internal error, can't find JdbcDriver instance '" + id + "'");
         }
         for (int ii=0; ii<msgArr.length; ii++) {
            MsgQosData msgQosData = (MsgQosData)((MsgUnit)msgArr[ii].getMsgUnit()).getQosData();
            driver.update(msgQosData.getSender().getAbsoluteName(), msgArr[ii].getContent());
         }
         String[] ret = new String[msgArr.length];
         for (int ii=0; ii<ret.length; ii++)
            ret[ii] = Constants.RET_OK;
         return ret;
View Full Code Here

Examples of org.xmlBlaster.util.qos.MsgQosData

         Thread.currentThread().dumpStack();
         throw new XmlBlasterException(glob, ErrorCode.INTERNAL_UNKNOWN, ME, "Internal error, can't find JdbcDriver instance '" + id + "'");
      }
      for (int ii=0; ii<msgArr.length; ii++) {
         try {
            MsgQosData msgQosData = (MsgQosData)((MsgUnit)msgArr[ii].getMsgUnit()).getQosData();
            driver.update(msgQosData.getSender().getAbsoluteName(), msgArr[ii].getContent());
         } catch (Throwable e) {
            throw new XmlBlasterException(glob, ErrorCode.COMMUNICATION_NOCONNECTION, ME,
               "JDBC Callback of " + ii + "th message to client [" + callbackAddress.getSecretSessionId() + "] failed.", e);
         }
      }
View Full Code Here

Examples of org.xmlBlaster.util.qos.MsgQosData

       buf.append("'/>");
       buf.append("</qos>");
       String xml = buf.toString();
       System.out.println(xml);
       MsgQosSaxFactory f = new MsgQosSaxFactory(Global.instance());
       MsgQosData data = f.readObject(xml);
       System.out.println(data.getSubscriptionId());
      
       buf = new XmlBuffer(256);
       buf.appendAttributeEscaped(txt);
       String tmp = buf.toString();
       System.out.print("Unescaped " + XmlBuffer.unEscapeXml(tmp));
View Full Code Here

Examples of org.xmlBlaster.util.qos.MsgQosData

         assertEquals("", msgUnitWrapper.getUniqueId(), newWrapper.getUniqueId());
         assertEquals("", msgUnitWrapper.getLogId(), newWrapper.getLogId());
         assertEquals("", msgUnitWrapper.isInternal(), newWrapper.isInternal());
         assertEquals("", msgUnitWrapper.getEmbeddedType(), newWrapper.getEmbeddedType());

         MsgQosData qos = newWrapper.getMsgQosData();
         assertEquals("", false, qos.isVolatile());
         assertEquals("", true, qos.isPersistent());
         assertEquals("", true, qos.isReadonly());
         assertEquals("", "Gesa", qos.getSender().getLoginName());

         assertEquals("", 3, qos.getRouteNodes().length);
         assertEquals("", 2, qos.getRouteNodes()[0].getStratum());
         assertEquals("", 0, qos.getRouteNodes()[2].getStratum());
         assertEquals("", 9408630500L, qos.getRouteNodes()[0].getTimestamp().getTimestamp());
         assertEquals("", true, qos.getRouteNodes()[0].getDirtyRead());
         assertEquals("", false, qos.getRouteNodes()[1].getDirtyRead());
         assertEquals("", false, qos.getRouteNodes()[2].getDirtyRead());

         assertEquals("", PriorityEnum.HIGH_PRIORITY.toString(), qos.getPriority().toString());
         assertEquals("", timestamp.getTimestamp(), qos.getRcvTimestamp().getTimestamp());
         System.out.println("SUCCESS BEFORE: " + msgUnitWrapper.toXml());
         System.out.println("SUCCESS AFTER: " + newWrapper.toXml());

         // The remaing life changes so we can't compare the XML strings directly:
View Full Code Here

Examples of org.xmlBlaster.util.qos.MsgQosData

      try {

         byte[] content = "this is the content".getBytes();
         PublishKey key = new PublishKey(glob, "someKey");
         PublishQosServer publishQosServer = new PublishQosServer(glob, "<qos><persistent/></qos>");
         MsgQosData msgQosData = publishQosServer.getData();
         ((MsgQosSaxFactory)glob.getMsgQosFactory()).sendRemainingLife(false); // so we can compare the toXml() directly
         // populate it
         String state = Constants.STATE_EXPIRED;
         msgQosData.setState(state);
         msgQosData.setSubscriptionId("someId");
         msgQosData.setPersistent(true);
         msgQosData.setForceUpdate(false);
         msgQosData.setReadonly(true);

         msgQosData.setSender(new SessionName(glob, "somebody"));
         msgQosData.setRedeliver(4);
         msgQosData.setQueueSize(1000L);
         msgQosData.setQueueIndex(500L);
         //msgQosData.addRouteInfo(null);
         //msgQosData.dirtyRead(null);//NodeId
         msgQosData.setPriority(PriorityEnum.LOW4_PRIORITY);
         msgQosData.setFromPersistenceStore(true);
         msgQosData.setLifeTime(4000L);
         msgQosData.setRemainingLifeStatic(6000L);
         MsgUnit msgUnit  = new MsgUnit(key.toXml(), content, msgQosData.toXml());

         log.fine("Testing" + msgQosData.toXml());

         SessionName receiver = new SessionName(glob, "receiver1");
         String subscriptionId = "subid";
         int redeliverCounter = 2;
         boolean updateOneway = true;
         org.xmlBlaster.engine.ServerScope global = new org.xmlBlaster.engine.ServerScope();
         MsgUnitWrapper msgWrapper = new MsgUnitWrapper(glob, msgUnit, queue.getStorageId());
         MsgQueueUpdateEntry entry = new MsgQueueUpdateEntry(global, msgWrapper, queue.getStorageId(),
                                         receiver, subscriptionId, updateOneway);
         entry.incrRedeliverCounter();
         entry.incrRedeliverCounter();

         queue.put(entry, false);
         I_QueueEntry returnEntry = queue.peek();

         boolean isUpdate = (returnEntry instanceof MsgQueueUpdateEntry);
         assertTrue("updateEntry: the return value is not an update ", isUpdate);
        
         MsgQueueUpdateEntry updateEntry = (MsgQueueUpdateEntry)returnEntry;

         assertEquals("The subscriptionId of the entry is different ", subscriptionId, updateEntry.getSubscriptionId());
         assertEquals("The state of the entry is different ", state, updateEntry.getState());
         assertEquals("The redeliverCounter of the entry is different ", redeliverCounter, updateEntry.getRedeliverCounter());
         assertEquals("The priority of the entry is different ", entry.getPriority(), updateEntry.getPriority());
         assertEquals("The oneway of the entry is different ", updateOneway, updateEntry.updateOneway());
         assertEquals("The persistent of the entry is different ", entry.isPersistent(), updateEntry.isPersistent());
         assertEquals("The receiver of the entry is different ", entry.getReceiver().toString(), updateEntry.getReceiver().toString());
         assertEquals("The uniqueId of the entry is different ", entry.getUniqueId(), updateEntry.getUniqueId());
         assertEquals("The msgUnitWrapperUniqueId of the entry is different ", entry.getMsgUnitWrapperUniqueId(), updateEntry.getMsgUnitWrapperUniqueId());
         assertEquals("The topic oid of the entry is different ", entry.getKeyOid(), updateEntry.getKeyOid());
         assertEquals("The topic oid of the entry is different ", entry.getStorageId().getId(), updateEntry.getStorageId().getId());
         log.info("SUCCESS: MsgQueueUpdateEntry: Persistent fields are read as expected");

         MsgUnit retMsgUnit = null;
         try {
            retMsgUnit = updateEntry.getMsgUnit();
         }
         catch (Throwable e) {  // Should not happen for RAM queue
            log.severe("Lookup failed, probably engine.Global has no Requestbroker, wi ignore the problem: " + e.getMessage());
            e.printStackTrace();
            return;
         }
         MsgQosData retMsgQosData = updateEntry.getMsgQosData();

         log.fine("Received" + retMsgQosData.toXml());

         // check message unit:
         assertEquals("The key of the message unit is different ", key.getOid(), retMsgUnit.getKeyData().getOid());
         assertEquals("The content of the message unit is different ", new String(retMsgUnit.getContent()), new String(content));
         //assertEquals("The qos of the message unit is different ", retMsgUnit.getQosData().isPersistent(), publishQosServer.isPersistent());
         //assertEquals("The qos of the message unit is different OLD="+oldXml+" NEW="+newXml, oldXml, newXml);

         assertEquals("msgQosData check failure: getSubscriptionId      ", msgQosData.getSubscriptionId(), retMsgQosData.getSubscriptionId());
//         assertEquals("msgQosData check failure: getPersistent             ", msgQosData.getPersistent(), retMsgQosData.getPersistent());
//         assertEquals("msgQosData check failure: getForceUpdate         ", msgQosData.getForceUpdate(), retMsgQosData.getForceUpdate());
//         assertEquals("msgQosData check failure: getReadOnly            ", msgQosData.getReadOnly(), retMsgQosData.getReadOnly());
         assertEquals("msgQosData check failure: getSender              ", msgQosData.getSender().toString(), retMsgQosData.getSender().toString());
         assertEquals("msgQosData check failure: getRedeliver           ", msgQosData.getRedeliver(), retMsgQosData.getRedeliver());
         assertEquals("msgQosData check failure: getQueueSize           ", msgQosData.getQueueSize(), retMsgQosData.getQueueSize());
         assertEquals("msgQosData check failure: getQueueIndex          ", msgQosData.getQueueIndex(), retMsgQosData.getQueueIndex());
         assertEquals("msgQosData check failure: getPriority            ", msgQosData.getPriority().getInt(), retMsgQosData.getPriority().getInt());
//         assertEquals("msgQosData check failure: getFromPersistentStore ", msgQosData.getFromPersistentStore(), retMsgQosData.getFromPersistentStore());
         assertEquals("msgQosData check failure: getLifeTime            ", msgQosData.getLifeTime(), retMsgQosData.getLifeTime());
         //assertEquals("msgQosData check failure: getRemainingLifeStatic ", msgQosData.getRemainingLifeStatic(), retMsgQosData.getRemainingLifeStatic());
         assertEquals("msgQosData check failure: receiver", receiver, updateEntry.getReceiver());

         queue.removeRandom(returnEntry); //just for cleaning up
View Full Code Here

Examples of org.xmlBlaster.util.qos.MsgQosData

      try {

         byte[] content = "this is the content".getBytes();
         PublishKey key = new PublishKey(glob, "someKey");
         PublishQosServer publishQosServer = new PublishQosServer(glob, "<qos><persistent/></qos>");
         MsgQosData msgQosData = publishQosServer.getData();
         ((MsgQosSaxFactory)glob.getMsgQosFactory()).sendRemainingLife(false); // so we can compare the toXml() directly
         // populate it
         msgQosData.setState("state");
         msgQosData.setSubscriptionId("someId");
         msgQosData.setPersistent(true);
         msgQosData.setForceUpdate(false);
         msgQosData.setReadonly(true);

         msgQosData.setSender(new SessionName(glob, "somebody"));
         msgQosData.setRedeliver(4);
         msgQosData.setQueueSize(1000L);
         msgQosData.setQueueIndex(500L);
         //msgQosData.addRouteInfo(null);
         //msgQosData.dirtyRead(null);//NodeId
         msgQosData.setPriority(PriorityEnum.LOW4_PRIORITY);
         msgQosData.setFromPersistenceStore(true);
         msgQosData.setLifeTime(4000L);
         msgQosData.setRemainingLifeStatic(6000L);
         MsgUnit msgUnit  = new MsgUnit(key.toXml(), content, msgQosData.toXml());

         log.fine("Testing" + msgQosData.toXml());

         org.xmlBlaster.engine.ServerScope global = new org.xmlBlaster.engine.ServerScope();
         MsgUnitWrapper msgWrapper = new MsgUnitWrapper(glob, msgUnit, queue.getStorageId());
         MsgQueueHistoryEntry entry = new MsgQueueHistoryEntry(global, msgWrapper, queue.getStorageId());

         queue.put(entry, false);
         I_QueueEntry returnEntry = queue.peek();

         boolean isHistory = (returnEntry instanceof MsgQueueHistoryEntry);
         assertTrue("historyEntry: the return value is not an update ", isHistory);
        
         MsgQueueHistoryEntry historyEntry = (MsgQueueHistoryEntry)returnEntry;

         assertEquals("The priority of the entry is different ", entry.getPriority(), historyEntry.getPriority());
         assertEquals("The persistent of the entry is different ", entry.isPersistent(), historyEntry.isPersistent());
         // The history queue is s LIFO, we have inverted the unique key
         assertEquals("The uniqueId of the entry is different ", entry.getUniqueId(), historyEntry.getUniqueId());
         assertEquals("The msgUnitWrapperUniqueId of the entry is different ", entry.getMsgUnitWrapperUniqueId(), historyEntry.getMsgUnitWrapperUniqueId());
         assertEquals("The topic oid of the entry is different ", entry.getKeyOid(), historyEntry.getKeyOid());
         assertEquals("The topic oid of the entry is different ", entry.getStorageId().getId(), historyEntry.getStorageId().getId());
         log.info("Persistent fields are read as expected");

         MsgUnit retMsgUnit = null;
         try {
            retMsgUnit = historyEntry.getMsgUnit();
         }
         catch (Throwable e) {  // Should not happen for RAM queue
            log.severe("Lookup failed, probably engine.Global has no Requestbroker, wi ignore the problem: " + e.getMessage());
            e.printStackTrace();
            return;
         }
         MsgQosData retMsgQosData = historyEntry.getMsgQosData();

         log.fine("Received" + retMsgQosData.toXml());

         // check message unit:
         assertEquals("The key of the message unit is different ", key.getOid(), retMsgUnit.getKeyData().getOid());
         assertEquals("The content of the message unit is different ", new String(retMsgUnit.getContent()), new String(content));
         //oldXml = oldXml.substring(oldXml.indexOf("remainingLife=");
         //String newXml = retMsgUnit.getQosData().toXml().trim();  TODO: strip remaining life first
         //assertEquals("The qos of the message unit is different OLD="+oldXml+" NEW="+newXml, oldXml, newXml); TODO

         assertEquals("msgQosData check failure: getSubscriptionId      ", msgQosData.getSubscriptionId(), retMsgQosData.getSubscriptionId());
         assertEquals("msgQosData check failure: getSender              ", msgQosData.getSender().toString(), retMsgQosData.getSender().toString());
         assertEquals("msgQosData check failure: getRedeliver           ", msgQosData.getRedeliver(), retMsgQosData.getRedeliver());
         assertEquals("msgQosData check failure: getQueueSize           ", msgQosData.getQueueSize(), retMsgQosData.getQueueSize());
         assertEquals("msgQosData check failure: getQueueIndex          ", msgQosData.getQueueIndex(), retMsgQosData.getQueueIndex());
         assertEquals("msgQosData check failure: getPriority            ", msgQosData.getPriority().getInt(), retMsgQosData.getPriority().getInt());
         assertEquals("msgQosData check failure: getLifeTime            ", msgQosData.getLifeTime(), retMsgQosData.getLifeTime());

         queue.removeRandom(returnEntry); //just for cleaning up

         log.info("successfully completed tests for the historyEntry");
View Full Code Here

Examples of org.xmlBlaster.util.qos.MsgQosData

   public void testPluginConfigParser() {
      log.info("start");
      String xml = "<![CDATA[<qos><expiration lifeTime='4000'/></qos>]]>";
      try {
         MsgQosData data = getQosData(xml);
         assertEquals("Wrong lifetime", 4000L, data.getLifeTime());
      }
      catch (XmlBlasterException e) {
         assertTrue(ME + " parsing failed for '" + xml + "'", false);
      }
      /*
      xml = "&lt;![CDATA[<qos><expiration lifeTime='4000'/></qos>]]&gt;";
      try {
         MsgQosData data = getQosData(xml);
         assertEquals("Wrong lifetime", 4000L, data.getLifeTime());
      }
      catch (XmlBlasterException e) {
         assertTrue(ME + " parsing failed for '" + xml + "'", false);
      }
      */

      xml = "<qos><expiration lifeTime='4000'/></qos>";
      try {
         MsgQosData data = getQosData(xml);
         assertEquals("Wrong lifetime", 4000L, data.getLifeTime());
      }
      catch (XmlBlasterException e) {
         assertTrue(ME + " parsing failed for '" + xml + "'", false);
      }

      xml = "<qos><![CDATA[<expiration lifeTime='4000'/>]]></qos>";
      try {
         MsgQosData data = getQosData(xml);
         // unless you change the parsing in MsgQosData
         assertEquals("Wrong lifetime", -1L, data.getLifeTime());
      }
      catch (XmlBlasterException e) {
         assertTrue(ME + " parsing failed for '" + xml + "'", false);
      }
     
View Full Code Here

Examples of org.xmlBlaster.util.qos.MsgQosData

    * Check if the given message (usually published) is the one we hold (usually updated).
    * throws a junit assert on error
    * @param msgUnit the expected message
    */
   public void compareMsg(MsgUnit msgUnit) {
      MsgQosData qos = (MsgQosData)msgUnit.getQosData();
      assertEquals("The keyOid is wrong", msgUnit.getKeyOid(), updateKey.getOid());
      assertEquals("The persistence flag is lost", qos.isPersistent(), updateQos.isPersistent());
      assertEquals("The message content length is corrupted", msgUnit.getContent().length, content.length);
      assertTrue("The message content is corrupted, expected='"+
                 msgUnit.getContentStr()+"' but was '"+new String(content)+"'", msgUnit.sameContent(content));
   }  
View Full Code Here

Examples of org.xmlBlaster.util.qos.MsgQosData

         "  <isPublish/>\n" +
         "  <clientProperty name='StringKey' type=''><![CDATA[Bla<BlaBla]]></clientProperty>\n" +
         "</qos>";     
     
      MsgQosSaxFactory parser = new MsgQosSaxFactory(this.glob);
      MsgQosData data = parser.readObject(xml);
      ClientProperty prop = data.getClientProperty("StringKey");
      System.out.println(prop.toXml());
      assertEquals("", true, prop.isBase64());
     
   }
View Full Code Here

Examples of org.xmlBlaster.util.qos.MsgQosData

      assertEquals("", true, prop.isBase64());
     
   }

   public void testClientPropertyParsingWithUntrimmedSpaces() throws Exception {
      MsgQosData data = new MsgQosData(this.glob, MethodName.PUBLISH);
      String name1 = "leadingSpaces";
      String val1 = "  val1";
      String name2 = "endingSpaces";
      String val2 = "val2  ";
      String name3 = "bothSpaces";
      String val3 = "  val3  ";
      String name4 = "singleSpace";
      String val4 = " val4 ";
      ClientProperty prop1 = new ClientProperty(name1, null, null, val1);
      ClientProperty prop2 = new ClientProperty(name2, null, null, val2);
      ClientProperty prop3 = new ClientProperty(name3, null, null, val3);
      ClientProperty prop4 = new ClientProperty(name4, null, null, val4);
      data.addClientProperty(prop1);
      data.addClientProperty(prop2);
      data.addClientProperty(prop3);
      data.addClientProperty(prop4);
      String xml = data.toXml();
      System.out.println("The content of the qos is '" + xml + "'");
      MsgQosSaxFactory parser = new MsgQosSaxFactory(this.glob);
      MsgQosData data1 = parser.readObject(xml);
      assertEquals(name1, val1, data1.getClientProperty(name1).getStringValue());
      assertEquals(name2, val2, data1.getClientProperty(name2).getStringValue());
      assertEquals(name3, val3, data1.getClientProperty(name3).getStringValue());
      assertEquals(name4, val4, data1.getClientProperty(name4).getStringValue());
     
   }
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.