Package org.xmlBlaster.client.qos

Examples of org.xmlBlaster.client.qos.GetReturnQos


         GetKey gk = new GetKey(glob, "HelloWorld3");
         GetQos gq = new GetQos(glob);
         MsgUnit[] msgs = con.get(gk, gq);
         if (msgs.length > 0) {
            GetReturnQos grq = new GetReturnQos(glob, msgs[0].getQos());
            log.info("Accessed xmlBlaster message with content '" + new String(msgs[0].getContent()) +
                      "' and status=" + grq.getState());
         }


         SubscribeKey sk = new SubscribeKey(glob, "HelloWorld3");
         SubscribeQos sq = new SubscribeQos(glob);
View Full Code Here


            msgs = con.get(gk.toXml(), gq.toXml());
         }

         for(int imsg=0; imsg<msgs.length; imsg++) {
            GetReturnKey grk = new GetReturnKey(glob, msgs[imsg].getKey());
            GetReturnQos grq = new GetReturnQos(glob, msgs[imsg].getQos());

            System.out.println("");
            System.out.println("============= START #" + (imsg+1) + " '" + grk.getOid() + "' =======================");
            log.info("Receiving update #" + (imsg+1) + " of a message ...");
            System.out.println("<xmlBlaster>");
            System.out.println(msgs[imsg].toXml("", 100, true));
            System.out.println("</xmlBlaster>");
            System.out.println("============= END #" + (imsg+1) + " '" + grk.getOid() + "' =========================");
            System.out.println("");

            if (saveToFile) {
               String fileName = grk.getOid()+"-"+grq.getRcvTimestamp().getTimestamp();
               try {
                  FileLocator.writeFile(fileName, msgs[imsg].toXml("").getBytes());
               }
               catch (XmlBlasterException e) {
                  System.out.println("Can't dump content to file '" + fileName + "': " + e.toString());
View Full Code Here

         try {
            GetKey gk = new GetKey(glob, "HelloWorldVolatile2");
            GetQos gq = new GetQos(glob);
            MsgUnit[] msgs = con.get(gk, gq);
            if (msgs.length > 0) {
               GetReturnQos grq = new GetReturnQos(glob, msgs[0].getQos());
               log.severe("Did not expect any message as it was volatile");
            }
         }
         catch (XmlBlasterException e) {
            log.severe("Didn't expect an exception in get(): " + e.getMessage());
View Full Code Here

               GetKey gk = new GetKey(glob, "Banking");
               GetQos gq = new GetQos(glob);
               try {
                  MsgUnit[] msgs = con.get(gk, gq);
                  if (msgs.length > 0) {
                     GetReturnQos grq = new GetReturnQos(glob, msgs[0].getQos());
                     log.info("Accessed xmlBlaster message with content '" + new String(msgs[0].getContent()) +
                               "' and status=" + grq.getState());
                  }
                  else {
                     log.info("No message matched get() call on " + gk.getOid());
                  }
               }
View Full Code Here

         assertEquals("Got wrong number of messages", 1, msgArr.length);
         log.info("Success, got the message '" + msgArr[0].getKey() + "'");
         if (log.isLoggable(Level.FINEST)) log.finest(msgArr[0].toXml());

         GetReturnQos getQos = new GetReturnQos(glob, msgArr[0].getQos());
         assertEquals("Sender is corrupted", senderName, getQos.getSender().getLoginName());
         log.info("Get success from sender " + getQos.getSender());

         assertEquals("Corrupted content", senderContent, new String(msgArr[0].getContent()));
      } catch(XmlBlasterException e) {
         log.severe("XmlBlasterException for trying to get a message: " + e.getMessage());
         assertTrue("Couldn't get() an existing message", false);
View Full Code Here

            "      <node id='frodo' stratum='1' timestamp='9408630538' dirtyRead='false'/>\n" +
            "      <node id='heron' stratum='0' timestamp='9408630564'/>\n" +
            "   </route>\n" +
            "</qos>\n";

         GetReturnQos qos = new GetReturnQos(glob, xml);

         assertEquals("", false, qos.isVolatile());
         assertEquals("", true, qos.isPersistent());
         assertEquals("", false, 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, qos.getPriority());
         assertEquals("", timestamp.getTimestamp(), qos.getRcvTimestamp().getTimestamp());
      }
      catch (XmlBlasterException e) {
         fail("testGetReturnQos failed: " + e.toString());
      }
View Full Code Here

         try {
            GetKey gk = new GetKey(glob, "HelloWorldVolatile");
            GetQos gq = new GetQos(glob);
            MsgUnit[] msgs = con.get(gk, gq);
            if (msgs.length > 0) {
               GetReturnQos grq = new GetReturnQos(glob, msgs[0].getQos());
               log.severe("Did not expect any message as it was volatile");
            }
         }
         catch (XmlBlasterException e) {
            log.severe("Didn't expect an exception in get(): " + e.getMessage());
View Full Code Here


            GetKey gk = new GetKey(con.getGlobal(), "AllProtocols");
            GetQos gq = new GetQos(con.getGlobal());
            MsgUnit[] msgs = con.get(gk.toXml(), gq.toXml());
            GetReturnQos grq = new GetReturnQos(con.getGlobal(), msgs[0].getQos());

            log.info("Accessed xmlBlaster message with content '" + new String(msgs[0].getContent()) +
                         "' and status=" + grq.getState());


            SubscribeKey sk = new SubscribeKey(con.getGlobal(), "AllProtocols");
            SubscribeQos sq = new SubscribeQos(con.getGlobal());
            SubscribeReturnQos subRet = con.subscribe(sk.toXml(), sq.toXml());
View Full Code Here

            GetQos gq = new GetQos(glob);

            for (int i=0; i<10; i++) {
               MsgUnit[] msgs = con.getCached(gk, gq);
               assertEquals(this.synchronousCache.toXml(""), 1, msgs.length);
               GetReturnQos grq = new GetReturnQos(glob, msgs[0].getQos());
               assertEquals("", 1, this.synchronousCache.getNumQueriesCached());
               log.info("Accessed xmlBlaster message with content '" + new String(msgs[0].getContent()) +
                              "' and status=" + grq.getState());
            }

            sendErase(publishOidArr[0]);
            assertEquals("", 0, this.synchronousCache.getNumQueriesCached());
            sendErase(publishOidArr[2]);
         }
         catch (XmlBlasterException e) {
            log.severe("testCachedAccess() failed: " + e.getMessage());
            fail(e.getMessage());
         }
         assertEquals("Unexpected update arrived", 0, this.updateInterceptor.waitOnUpdate(1000L, 0));
      }

      {
         log.info("Entering testCachedAccess with updated MsgUnit ...");
         try {
            PublishReturnQos publishReturnQos = publishMsg(publishOidArr[0], contentArr[0]);

            GetKey gk = new GetKey(glob, publishOidArr[0]);
            GetQos gq = new GetQos(glob);

            for (int i=0; i<5; i++) {
               MsgUnit[] msgs = con.getCached(gk, gq);
               GetReturnQos grq = new GetReturnQos(glob, msgs[0].getQos());
               assertEquals(this.synchronousCache.toXml(""), 1, msgs.length);
               assertEquals("", 1, this.synchronousCache.getNumQueriesCached());
               assertEquals("", publishReturnQos.getRcvTimestamp(), grq.getRcvTimestamp());
               assertEquals("", contentArr[0], msgs[0].getContentStr());
               log.info("Accessed xmlBlaster message with content '" + new String(msgs[0].getContent()) +
                              "' and status=" + grq.getState() + " rcv=" + grq.getRcvTimestamp());
            }

            // Now publish again an check if cache is updated
            String contentNew = contentArr[0]+"-NEW";
            publishReturnQos = publishMsg(publishOidArr[0], contentNew);
            try { Thread.sleep(200L); } catch( InterruptedException i) {}   // Wait 200 milli seconds, until all updates are processed ...
            for (int i=0; i<5; i++) {
               MsgUnit[] msgs = con.getCached(gk, gq);
               GetReturnQos grq = new GetReturnQos(glob, msgs[0].getQos());
               assertEquals(this.synchronousCache.toXml(""), 1, msgs.length);
               assertEquals("", 1, this.synchronousCache.getNumQueriesCached());
               assertEquals("", publishReturnQos.getRcvTimestamp().getTimestamp(), grq.getRcvTimestamp().getTimestamp());
               assertEquals("", publishReturnQos.getKeyOid(), msgs[0].getKeyOid());
               assertEquals("", contentNew, msgs[0].getContentStr());
               log.info("Accessed xmlBlaster message with content '" + new String(msgs[0].getContent()) +
                              "' and status=" + grq.getState() + " rcv=" + grq.getRcvTimestamp());
            }

            sendErase(publishOidArr[0]);
            assertEquals("", 0, this.synchronousCache.getNumQueriesCached());
         }
         catch (XmlBlasterException e) {
            log.severe("testCachedAccess() failed: " + e.getMessage());
            fail(e.getMessage());
         }
         assertEquals("Unexpected update arrived", 0, this.updateInterceptor.waitOnUpdate(1000L, 0));
      }

      {
         log.info("Entering testCachedAccess with XPATH ...");
         try {
            PublishReturnQos publishReturnQos0 = publishMsg(publishOidArr[0], contentArr[0]);
            PublishReturnQos publishReturnQos1 = publishMsg(publishOidArr[1], contentArr[1]);
            publishMsg(publishOidArr[2], contentArr[2]);
            try { Thread.sleep(200L); } catch( InterruptedException i) {}   // Wait 200 milli seconds, until all updates are processed ...

            // This should match [0] and [1] msg:
            GetKey gk = new GetKey(glob, "//key[starts-with(@oid,'oid-')]", Constants.XPATH);
            GetQos gq = new GetQos(glob);

            for (int i=0; i<10; i++) {
               MsgUnit[] msgs = con.getCached(gk, gq);
               assertEquals("", 2, msgs.length);
               GetReturnQos grq0 = new GetReturnQos(glob, msgs[0].getQos());
               GetReturnQos grq1 = new GetReturnQos(glob, msgs[1].getQos());
               assertEquals(this.synchronousCache.toXml(""), 2, msgs.length);
               assertEquals(this.synchronousCache.toXml(""), 1, this.synchronousCache.getNumQueriesCached());
               log.info(" publishReturnQos0.getRcvTimestamp()=" + publishReturnQos0.getRcvTimestamp() +
                            " publishReturnQos1.getRcvTimestamp()=" + publishReturnQos1.getRcvTimestamp() +
                            " grq0.getRcvTimestamp()=" + grq0.getRcvTimestamp() +
                            " grq1.getRcvTimestamp()=" + grq1.getRcvTimestamp());
               assertTrue("", publishReturnQos0.getRcvTimestamp().equals(grq0.getRcvTimestamp()) ||
                              publishReturnQos0.getRcvTimestamp().equals(grq1.getRcvTimestamp()));
               assertTrue("", publishReturnQos1.getRcvTimestamp().equals(grq0.getRcvTimestamp()) ||
                              publishReturnQos1.getRcvTimestamp().equals(grq1.getRcvTimestamp()));
               assertTrue("", !grq0.getRcvTimestamp().equals(grq1.getRcvTimestamp()));
               assertEquals("", 2, msgs.length);
               log.info("Accessed " + msgs.length + " xmlBlaster messages with content '" +
                              new String(msgs[0].getContent()) +
                              "' and '" + new String(msgs[1].getContent()) + "' and status=" + grq0.getState());
            }
View Full Code Here

        
         assertEquals("Got wrong number of messages", 1, msgArr.length);
         log.info("Success, got the message '" + msgArr[0].getKey() + "'");
         if (log.isLoggable(Level.FINEST)) log.finest(msgArr[0].toXml());

         GetReturnQos getQos = new GetReturnQos(glob, msgArr[0].getQos());
         assertEquals("Sender is corrupted", loginName, getQos.getSender().getLoginName());
         log.info("Get success from sender " + getQos.getSender());
        
         assertEquals("Corrupted content", senderContent, new String(msgArr[0].getContent()));
      } catch(XmlBlasterException e) {
         log.severe("XmlBlasterException for trying to get a message: " + e.getMessage());
         assertTrue("Couldn't get() an existing message", false);
View Full Code Here

TOP

Related Classes of org.xmlBlaster.client.qos.GetReturnQos

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.