Package org.xmlBlaster.client.key

Examples of org.xmlBlaster.client.key.SubscribeKey


         if (log.isLoggable(Level.FINE)) log.fine("Subscribing ...");
        
         String passwd = "secret";
        
         SubscribeKey subKeyW = new SubscribeKey(glob, publishOid1);
         String subKey = subKeyW.toXml(); // "<key oid='" + publishOid1 + "' queryType='EXACT'></key>";
        
         SubscribeQos subQosW = new SubscribeQos(glob); // "<qos></qos>";
         String subQos = subQosW.toXml();
        
         manyClients = new Client[numSubscribers];
         if (maxSubPerCon >0 ) {
            // Check if reasonably
            if numSubscribers %  maxSubPerCon!= 0) {
             assertTrue("numSubscribers not divadable by breakpoint", false);
            }
           
            manyConnections = new I_XmlBlasterAccess[numSubscribers/maxSubPerCon];
         } // end of if ()
        
        
         long usedBefore = getUsedServerMemory();
        
         log.info("Setting up " + numSubscribers + " subscriber clients ...");

         int startNoThreads = ThreadLister.countThreads();
         //ThreadLister.listAllThreads(System.out);
         stopWatch = new StopWatch();
         for (int ii=0; ii<numSubscribers; ii++) {
            Client sub = new Client();
            sub.loginName = "Joe-" + ii;
            sub.oneConnection = useOneConnection;
            if (useOneConnection) {
               // Should we distribute among a few connections
               if (maxSubPerCon >0) {
                  if ii % maxSubPerCon == 0) {
                     ci++;
                     try {
                        log.fine("Creating connection no: " +ci);
                        Global gg = globalUtil.getClone(glob);
                        // Try to reuse the same ORB to avoid too many threads:
                        if ("IOR".equals(gg.getProperty().get("protocol","IOR")) && ci > 0) {
                           gg.addObjectEntry(Constants.RELATING_CLIENT+":org.xmlBlaster.util.protocol.corba.OrbInstanceWrapper",
                                             (org.xmlBlaster.util.protocol.corba.OrbInstanceWrapper)manyConnections[ci-1].getGlobal().getObjectEntry(Constants.RELATING_CLIENT+":org.xmlBlaster.util.protocol.corba.OrbInstanceWrapper"));
                        }
                        manyConnections[ci] = gg.getXmlBlasterAccess();
                        ConnectQos connectQos = new ConnectQos(gg, sub.loginName, passwd); // "<qos></qos>"; During login this is manipulated (callback address added)
                        // If we have many subs on one con, we must raise the max size of the callback queue!
                        CbQueueProperty cbProp =connectQos.getSessionCbQueueProperty();
                        // algo is maxSubPerCon*4
                        cbProp.setMaxEntries(maxSubPerCon*1000);//This means we have a backlog of 1000 messages per subscriber as i normal when each con only have one subscriber!
                        //cbProp.setMaxBytes(4000);
                        //cbProp.setOnOverflow(Constants.ONOVERFLOW_BLOCK);
                        //connectQos.setSubjectQueueProperty(cbProp);
                        log.fine("Login qos: " +  connectQos.toXml());
                        ConnectReturnQos connectReturnQos = manyConnections[ci].connect(connectQos, this);
                        log.info("Connected maxSubPerCon=" + maxSubPerCon + " : " + connectReturnQos.toXml());
                     }
                     catch (Exception e) {
                        log.severe("Login failed: " + e.toString());
                        assertTrue("Login failed: " + e.toString(), false);
                     }
                    
                  } // end of if ()
                  sub.connection = manyConnections[ci];
               } else {
                  sub.connection = oneConnection;
               }
            }else {
               try {
                  Global gg = globalUtil.getClone(glob);
                  sub.connection = gg.getXmlBlasterAccess();
                  ConnectQos connectQos = new ConnectQos(gg, sub.loginName, passwd); // "<qos></qos>"; During login this is manipulated (callback address added)
                  ConnectReturnQos connectReturnQos = sub.connection.connect(connectQos, this);
                  log.info("Connected: " + connectReturnQos.toXml());
               }
               catch (Exception e) {
                  log.severe("Login failed: " + e.toString());
                  assertTrue("Login failed: " + e.toString(), false);
               }                                                       
            }
            try {
            sub.subscribeOid = sub.connection.subscribe(subKey, subQos).getSubscriptionId();
            log.fine("Client " + sub.loginName + " subscribed to " + subKeyW.getOid());
            } catch(XmlBlasterException e) {
               log.warning("XmlBlasterException: " + e.getMessage());
               assertTrue("subscribe - XmlBlasterException: " + e.getMessage(), false);
            }
           
View Full Code Here


            // SubscribeKey helps us to create this string:
            //   "<key oid='' queryType='XPATH'>" +
            //   "   /xmlBlaster/key/ClientSub-AGENT" +
            //   "</key>";
            SubscribeKey key = new SubscribeKey(glob, "/xmlBlaster/key/ClientSub-AGENT", "XPATH");

            // SubscribeKey helps us to create "<qos></qos>":
            SubscribeQos qos = new SubscribeQos(glob);

            try {
               subscriptionId = blasterConnection.subscribe(key.toXml(), qos.toXml()).getSubscriptionId();
               log.info("Subscribe done, there should be no Callback, subcriptionId=" + subscriptionId);
            } catch(XmlBlasterException e) {
               log.warning("XmlBlasterException: " + e.getMessage());
            }
         }
View Full Code Here

         ConnectQos qos = new ConnectQos(glob);
         con.connect(qos, this)// Login to xmlBlaster, register for updates

         // Subscribe for the volatile message
         SubscribeKey sk = new SubscribeKey(glob, "HelloWorldVolatile");
         SubscribeQos sq = new SubscribeQos(glob);
         SubscribeReturnQos subRet = con.subscribe(sk, sq);

         // Publish a volatile message
         PublishKey pk = new PublishKey(glob, "HelloWorldVolatile", "text/xml", "1.0");
View Full Code Here

         PublishKey pk = new PublishKey(glob, "Latency", "text/xml", "1.0");
         PublishQos pq = new PublishQos(glob);
         MsgUnit msgUnit = new MsgUnit(pk.toXml(), "Hi".getBytes(), pq.toXml());

         SubscribeKey sk = new SubscribeKey(glob, "Latency");
         SubscribeQos sq = new SubscribeQos(glob);
         con.subscribe(sk.toXml(), sq.toXml()).getSubscriptionId();

         int numSend = glob.getProperty().get("numSend", 10);

         for (int ii=0; ii<numSend; ii++) {
            startTime = System.currentTimeMillis();
View Full Code Here

      }
   }

   private void subscribe(String oid) {
      try {
         SubscribeKey sk = new SubscribeKey(glob, oid);
         SubscribeQos sq = new SubscribeQos(glob);
         SubscribeReturnQos srq = con.subscribe(sk.toXml(), sq.toXml());
         log.info("SUCCESS subscribe to '" + oid + "' returned state=" + srq.getState());
      } catch(XmlBlasterException e) {
         log.warning("XmlBlasterException: " + e.getMessage());
         fail("subscribe - XmlBlasterException: " + e.getMessage());
      }
View Full Code Here

            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());


            msgUnit = new MsgUnit(pk, "Ho".getBytes(), pq);
            PublishReturnQos prq = con.publish(msgUnit);
View Full Code Here

         log.info("connect return qos: " + retQos.toXml());
        
         SubscribeQos subQos = new SubscribeQos(this.connGlobal);
         subQos.setWantInitialUpdate(false);
         subQos.setMultiSubscribe(false);
         this.connGlobal.getXmlBlasterAccess().subscribe(new SubscribeKey(this.connGlobal, this.oid), subQos);
      }
      catch (XmlBlasterException ex) {
         ex.printStackTrace();
         fail("aborting since exception ex: " + ex.getMessage());
      }
View Full Code Here

   public void testSubscribeXPath()
   {
      log.info("Subscribing using XPath syntax ...");
      try {
        {
          SubscribeKey key = new SubscribeKey(glob, "//key/location[@dest='agent-192.168.10.218']", "XPATH");
          SubscribeQos qos = new SubscribeQos(glob);
          con.subscribe(key.toXml(), qos.toXml(),this);
        }

        {
          SubscribeKey key = new SubscribeKey(glob, "//key[@contentMimeExtended='action']/location[@dest='agent-192.168.10.218' and @driver='PSD1']", "XPATH");
          SubscribeQos qos = new SubscribeQos(glob);
          con.subscribe(key.toXml(), qos.toXml(), this);
        }
      }
      catch(XmlBlasterException e) {
        log.warning("XmlBlasterException: " + e.getMessage());
        assertTrue("publish - XmlBlasterException: " + e.getMessage(), false);
View Full Code Here

         qos.addClientProperty("threeKey", new Integer(55));
         MsgUnit msg = new MsgUnit(key, "message".getBytes(), qos);
         senderConnection.publish(msg);

         // subscribe
         senderConnection.subscribe(new SubscribeKey(this.glob, "clientProp"), new SubscribeQos(this.glob));

         waitOnUpdate(10000);

         senderConnection.erase(new EraseKey(this.glob, "clientProperty"), new EraseQos(this.glob));
         senderConnection.disconnect(new DisconnectQos(this.glob));
View Full Code Here

         I_XmlBlasterAccess blasterConnection = glob.getXmlBlasterAccess();
         blasterConnection.connect(loginQos, this)// Now we are connected to xmlBlaster MOM server.

         // Subscribe to messages with XPATH using some helper classes
         log.info("Subscribing #1 for anonymous callback class using XPath syntax ...");
         SubscribeKey key = new SubscribeKey(glob, "//DispatchTest", "XPATH");
         SubscribeQos qos = new SubscribeQos(glob);
         blasterConnection.subscribe(key, qos, new I_Callback() {
               public String update(String cbSessionId, UpdateKey updateKey, byte[] content, UpdateQos updateQos) {
                  log.info("Receiving message with specialized update() #1 ...");
                  numReceived1++;
                  System.out.println(updateKey.toXml());
                  System.out.println((new String(content)).toString());
                  System.out.println(updateQos.toXml());
                  return "";
               }
            });


         log.info("Subscribing #2 for anonymous callback class using XPath syntax ...");
         key = new SubscribeKey(glob, "A message id");
         blasterConnection.subscribe(key, qos, new I_Callback() {
               public String update(String cbSessionId, UpdateKey updateKey, byte[] content, UpdateQos updateQos) {
                  log.info("Receiving message with specialized update() #2 ...");
                  numReceived2++;
                  System.out.println(updateKey.toXml());
View Full Code Here

TOP

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

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.