Package org.xmlBlaster.client.key

Examples of org.xmlBlaster.client.key.GetKey


       * Query xmlBlaster.
       */
      MsgUnitRaw[] get(String queryString)
      {
         try {
            GetKey getKey = new GetKey(this.authenticate.getGlobal(), queryString, queryType);
            stop.restart();
            MsgUnitRaw[] msgArr = this.xmlBlasterImpl.get(this.addressServer, this.secretSessionId, getKey.toXml(), "<qos/>");
            log.info("Got " + msgArr.length + " messages for query '" + queryString + "'" + stop.nice());
            return msgArr;
         } catch(XmlBlasterException e) {
            log.severe("XmlBlasterException: " + e.getMessage());
            return new MsgUnitRaw[0];
View Full Code Here


    String mimeType = (String) req.getParameter("mimeType");
    String charset = (String) req.getParameter("charset");
    log.info(id + " Making the request for 'plainGet' with topic='" + topic + "' mimeType='"
        + mimeType + "' charset='" + charset + "'");
    res.setContentType("text/xml; charset=UTF-8");
    GetKey key = new GetKey(this.glob, topic);
    GetQos qos = new GetQos(this.glob);
    MsgUnit[] ret = this.xmlBlasterAccess.get(key, qos);
    if (ret != null && ret.length > 0) {
      if (ret.length > 1)
        log.warning(id + " " + ret.length
View Full Code Here

  private String getFeedback(HttpServletRequest req)
      throws XmlBlasterException, UnsupportedEncodingException {
    I_XmlBlasterAccess xmlBlaster = getXmlBlaster(req);
    String topicId = props.getProperty("smsFeedbackTopicId",
        "vehicle.sms.feedback");
    GetKey gk = new GetKey(xmlBlaster.getGlobal(), topicId);
    GetQos gq = new GetQos(xmlBlaster.getGlobal());
    MsgUnit[] msgs = xmlBlaster.getCached(gk, gq);
    if (msgs.length > 0) {
      // log(ME+ msgs.length + " msgs found ...");
      byte[] content = msgs[msgs.length - 1].getContent();
View Full Code Here

  private Position getCurrentPosition(HttpServletRequest req)
      throws XmlBlasterException {
    I_XmlBlasterAccess xmlBlaster = getXmlBlaster(req);
    String topicId = props.getProperty("gpsTopicId", "vehicle.location");
    GetKey gk = new GetKey(xmlBlaster.getGlobal(), topicId);
    GetQos gq = new GetQos(xmlBlaster.getGlobal());
    MsgUnit[] msgs = xmlBlaster.getCached(gk, gq);
    if (msgs.length > 0) {
      // log(ME+ msgs.length + " msgs found ...");
      byte[] content = msgs[msgs.length - 1].getContent();
View Full Code Here

      wrap.init(type, limit, confirm, queryStr);

      try {
         log.info("Sending command string:\n" + wrap.toXml());
         GetKey key = new GetKey(glob, "__sys__jdbc");
         key.wrap(wrap.toXml());
         GetQos qos = new GetQos(glob);
         // get() blocks until the query is finished ...
         MsgUnit[] msgUnitArr = corbaConnection.get(key.toXml(), qos.toXml());
         if (msgUnitArr.length > 0)
            System.out.println(new String(msgUnitArr[0].getContent()));
         else
            log.info("No results for your query");
      }
View Full Code Here

   /**
    * Retrieve a dump of xmlBlaster to analyse
    */
   private String getDump() {
      try {
         GetKey gk = new GetKey(glob, "__cmd:?dump");
         GetQos gq = new GetQos(glob);
         MsgUnit[] msgs = con.get(gk.toXml(), gq.toXml());
         assertEquals("Did not expect returned msg for get()", 1, msgs.length);
         return msgs[0].getContentStr();
      }
      catch (XmlBlasterException e) {
         fail("Didn't expect an exception in get(): " + e.getMessage());
View Full Code Here

         pq.addClientProperty("myAge", 84);
         MsgUnit msgUnit = new MsgUnit(pk, "Hi", pq);
         con.publish(msgUnit);


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

         try { Thread.sleep(1000); } catch( InterruptedException i) {} // Wait some time
         assertTrue(assertInUpdate, assertInUpdate == null);
         assertInUpdate = null;

         System.err.println("->Check if the message has reached the master node heron ...");
         GetKey gk = new GetKey(glob, oid);
         MsgUnit[] msgs = heronCon.get(gk.toXml(), null);
         assertTrue("Invalid msgs returned", msgs != null);
         assertEquals("Invalid number of messages returned", 1, msgs.length);
         assertTrue("Invalid message oid returned", msgs[0].getKey().indexOf(oid) > 0);
         log.info("SUCCESS: Got message:" + msgs[0].getKey());

         System.err.println("->Check if the message is available at the slave node bilbo ...");
         gk = new GetKey(glob, oid);
         gk.setDomain(domain);
         msgs = bilboCon.get(gk.toXml(), null);
         assertTrue("Invalid msgs returned", msgs != null);
         assertEquals("Invalid number of messages returned", 1, msgs.length);
         log.info("SUCCESS: Got message:" + msgs[0].getKey());

         System.err.println("->Trying to erase the message at the slave node ...");
         EraseKey ek = new EraseKey(glob, oid);
         ek.setDomain(domain);
         EraseQos eq = new EraseQos(glob);
         bilboCon.erase(ek.toXml(), eq.toXml());

         // Check if erased ...
         gk = new GetKey(glob, oid);
         msgs = heronCon.get(gk.toXml(), null);
         assertTrue("Invalid msgs returned", msgs != null);
         assertEquals("Invalid number of messages returned", 0, msgs.length);
         log.info("SUCCESS: Got no message after erase");

         System.err.println("***PublishTest: Publish a message to a cluster slave - frodo is offline ...");

         System.err.println("->Subscribe from heron, the message is currently erased ...");
         SubscribeKey sk = new SubscribeKey(glob, oid);
         sk.setDomain(domain);
         SubscribeQos sq = new SubscribeQos(glob);
         SubscribeReturnQos srq = heronCon.subscribe(sk.toXml(), sq.toXml(), new I_Callback() {
            public String update(String cbSessionId, UpdateKey updateKey, byte[] content, UpdateQos updateQos) {
               assertInUpdate = serverHelper.getHeronGlob().getId() + ": Receiving unexpected asynchronous update message";
               assertEquals(assertInUpdate, oid, updateKey.getOid());
               assertInUpdate = serverHelper.getHeronGlob().getId() + ": Receiving corrupted asynchronous update message";
               assertEquals(assertInUpdate, contentStr, new String(content));
               log.info("heronCon - Receiving asynchronous message '" + updateKey.getOid() + "' in " + oid + " handler, state=" + updateQos.getState());
               updateCounterHeron++;
               assertInUpdate = null;
               return "";
            }
         })// subscribe with our specific update handler
         try { Thread.sleep(1000); } catch( InterruptedException i) {} // Wait some time
         assertTrue(assertInUpdate, assertInUpdate == null);
         assertInUpdate = null;

         serverHelper.stopFrodo();

         System.err.println("->Check: heron hasn't got the message ...");
         gk = new GetKey(glob, oid);
         msgs = heronCon.get(gk.toXml(), null);
         assertTrue("Invalid msgs returned", msgs != null);
         assertEquals("Invalid number of messages returned", 0, msgs.length);
         log.info("SUCCESS: Got no message after erase");

         // publish again ...
View Full Code Here

               try { System.in.read(); } catch(java.io.IOException e) {}
            }
            msgs = con.receive(queryOid, queryMaxEntries, queryTimeout, queryConsumable);
         }
         else {
            GetKey gk = (oid.length() > 0) ? new GetKey(glob, oid) : new GetKey(glob, xpath, Constants.XPATH);
            if (domain != null) gk.setDomain(domain);
            GetQos gq = new GetQos(glob);
            gq.setWantContent(content);
           
            HistoryQos historyQos = new HistoryQos(glob);
            historyQos.setNumEntries(historyNumUpdates);
            historyQos.setNewestFirst(historyNewestFirst);
            gq.setHistoryQos(historyQos);
  
            if (filterQuery.length() > 0) {
               AccessFilterQos filter = new AccessFilterQos(glob, filterType, filterVersion, filterQuery);
               gq.addAccessFilter(filter);
            }
            if (clientPropertyMap != null) {
               Iterator it = clientPropertyMap.keySet().iterator();
               while (it.hasNext()) {
                  String key = (String)it.next();
                  gq.addClientProperty(key, clientPropertyMap.get(key).toString());
               }
               //Example for a typed property:
               //pq.getData().addClientProperty("ALONG", (new Long(12)));
            }

            log.info("GetKey=\n" + gk.toXml());
            log.info("GetQos=\n" + gq.toXml());

            if (interactive) {
               log.info("Hit a key to get '" + ((oid.length() > 0) ? oid : xpath) + "'");
               try { System.in.read(); } catch(java.io.IOException e) {}
            }

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

         MsgUnit msgUnit = new MsgUnit(pk, "Hi", pq);
         con.publish(msgUnit);

         // This should not be possible as the message was volatile
         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");
View Full Code Here

TOP

Related Classes of org.xmlBlaster.client.key.GetKey

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.