Package org.xmlBlaster.client

Examples of org.xmlBlaster.client.I_Callback


          + "/1");
      String password = props.getProperty("password", passwd);
      Global glob = new Global(props);
      this.xmlBlasterAccess = glob.getXmlBlasterAccess();
      ConnectQos qos = new ConnectQos(glob, sessionName, password);
      this.xmlBlasterAccess.connect(qos, new I_Callback() {
        public String update(String cbSessionId, UpdateKey updateKey,
            byte[] content, UpdateQos updateQos) {
          log("PullServler.update(): Ignoring update "
              + updateKey.getOid());
          return "";
View Full Code Here


      try {
         log.info("Connecting ...");
         con = glob.getXmlBlasterAccess();
         ConnectQos qos = new ConnectQos(glob, name, passwd);
         con.connect(qos, new I_Callback() {
               public String update(String cbSessionId, UpdateKey updateKey, byte[] content, UpdateQos updateQos) {
                  log.info("Reveiving asynchronous message '" + updateKey.getOid() + "' in default handler");
                  numUpdated++;
                  return "";
               }
View Full Code Here

      ConnectQos connectQos;
      try {
         Global glob1 = glob.getClone(null);
         con1 = glob1.getXmlBlasterAccess(); // Find orb
         connectQos = new ConnectQos(glob1, "con1", "secret");
         con1.connect(connectQos,  new I_Callback() {
            public String update(String cbSessionId, UpdateKey updateKey, byte[] content, UpdateQos updateQos) {
               log.info("Reveiving asynchronous message '" + updateKey.getOid() + "' in default handler");
               numReceived1++;
               assertEquals("Message not expected", "command-navigation", updateKey.getOid());
               messageArrived1.append("OK");
               return "";
            }
         });

         Global glob2 = glob.getClone(null);
         con2 = glob2.getXmlBlasterAccess(); // Find orb
         connectQos = new ConnectQos(glob2, "con2", "secret");
         con2.connect(connectQos,  new I_Callback() {
            public String update(String cbSessionId, UpdateKey updateKey, byte[] content, UpdateQos updateQos) {
               log.info("Reveiving asynchronous message '" + updateKey.getOid() + "' in default handler");
               numReceived2++;
               assertEquals("Message not expected", "command-radar-1", updateKey.getOid());
               messageArrived2.append("OK");
               return "";
            }
         });

         Global glob3 = glob.getClone(null);
         con3 = glob3.getXmlBlasterAccess(); // Find orb
         connectQos = new ConnectQos(glob3, "con3", "secret");
         con3.connect(connectQos,  new I_Callback() {
            public String update(String cbSessionId, UpdateKey updateKey, byte[] content, UpdateQos updateQos) {
               log.info("Reveiving asynchronous message '" + updateKey.getOid() + "' in default handler");
               numReceived3++;
               assertEquals("Message not expected", "command-radar-1", updateKey.getOid());
               messageArrived3.append("OK");
View Full Code Here

      try {
         if (attrs == null) { // 'old' behaviour
            if (this.alertSubscribeKey == null)
               return false;
            log.info("Registering on '" + this.alertSubscribeKey + "' for alerts");
            SubscribeReturnQos subRet = this.con.subscribe(this.alertSubscribeKey, this.alertSubscribeQos, new I_Callback() {
               public String update(String s, UpdateKey k, byte[] c, UpdateQos q) throws XmlBlasterException {
                  log.fine("Receiving alert message '" + k.getOid() + "'");
                  Map attrMap = clientPropertiesToMap(q.getClientProperties());
                  try {
                     momCb.update(k.getOid(), new ByteArrayInputStream(c), attrMap);
View Full Code Here

        try {
          SubscribeKey sk = topic.startsWith("XPATH:") ?
                          new SubscribeKey(glob, topic.substring(6), "XPATH") :
                          new SubscribeKey(glob, topic);
          SubscribeQos sq = new SubscribeQos(glob);
          SubscribeReturnQos subRet = this.con.subscribe(sk, sq, new I_Callback() {
            public String update(String s, UpdateKey k, byte[] c, UpdateQos q) throws XmlBlasterException {
               if (log.isLoggable(Level.FINE)) log.fine("Receiving xmlBlaster message " + k.getOid());
               Map attrMap = clientPropertiesToMap(q.getClientProperties());
               try {
                  momCb.update(k.getOid(), new ByteArrayInputStream(c), attrMap);
View Full Code Here

         // setup the receiver client which processes the request (usually another process) ...
            Global globReceiver = glob.getClone(null);
            receiver = globReceiver.getXmlBlasterAccess();

            ConnectQos qos = new ConnectQos(receiver.getGlobal(), receiverName, "secret");
            ConnectReturnQos conRetQos = receiver.connect(qos, new I_Callback() {
               public String update(String cbSessionId, UpdateKey updateKey, byte[] content, UpdateQos updateQos) {
                  log.info(receiverName+": Receiving asynchronous message '" + updateKey.getOid() + "' in receiver default handler");
                  log.info(receiverName+": Received: " + updateKey.toXml() + "\n <content>" + new String(content) + "</content>" + updateQos.toXml());

                  if (updateKey.isInternal()) return "";
View Full Code Here

      bulkSize = glob.getProperty().get("bulkSize", bulkSize);

      try {
         con = glob.getXmlBlasterAccess();
         ConnectQos qos = new ConnectQos(glob);
         conRetQos = con.connect(qos, new I_Callback() {

            public String update(String cbSessionId, UpdateKey updateKey, byte[] content, UpdateQos updateQos) {
               log.info("Receiving asynchronous message '" + updateKey.getOid() +
                               "' state=" + updateQos.getState() + " in default handler");
               return "";
View Full Code Here

      long lCount = 0L;

      try {
         con = glob.getXmlBlasterAccess();
         ConnectQos qos = new ConnectQos(glob);
         conRetQos = con.connect(qos, new I_Callback() {

            public String update(String cbSessionId, UpdateKey updateKey, byte[] content, UpdateQos updateQos) {
               log.info("Receiving asynchronous message '" + updateKey.getOid() +
                               "' state=" + updateQos.getState() + " in default handler");
               return "";
View Full Code Here

      interactive = glob.getProperty().get("interactive", interactive);

      try {
         con = glob.getXmlBlasterAccess();
         ConnectQos qos = new ConnectQos(glob);
         conRetQos = con.connect(qos, new I_Callback() {

            public String update(String cbSessionId, UpdateKey updateKey, byte[] content, UpdateQos updateQos) {
               log.info("Receiving asynchronous message '" + updateKey.getOid() +
                               "' state=" + updateQos.getState() + " in default handler");
               return "";
View Full Code Here

    * Than we try to access the message at heron
    */
   public void testPublish() {
      System.err.println("***PublishTest: Publish a message to a cluster slave ...");
      try {
         bilboCon = serverHelper.connect(serverHelper.getBilboGlob(), new I_Callback() {  // Login to xmlBlaster, register for updates
               public String update(String cbSessionId, UpdateKey updateKey, byte[] content, UpdateQos updateQos) {
                  assertInUpdate = serverHelper.getBilboGlob().getId() + ": Should not receive the message '" + updateKey.getOid() + "'";
                  fail(assertInUpdate); // This is routed to server, not to junit
                  return "";
               }
            });
         try { Thread.sleep(1000); } catch( InterruptedException i) {} // Wait some time
         assertTrue(assertInUpdate, assertInUpdate == null);
         assertInUpdate = null;

         PublishKey pk = new PublishKey(glob, oid, "text/plain", "1.0");
         pk.setDomain(domain);
         PublishQos pq = new PublishQos(glob);
         MsgUnit msgUnit = new MsgUnit(pk, contentStr, pq);
         PublishReturnQos prq = bilboCon.publish(msgUnit);
         log.info("Published message of domain='" + pk.getDomain() + "' and content='" + contentStr +
                                    "' to xmlBlaster node bilbo with IP=" + serverHelper.getBilboGlob().getProperty().get("bootstrapPort",0) +
                                    ", the returned QoS is: " + prq.getKeyOid());

         heronCon = serverHelper.connect(serverHelper.getHeronGlob(), new I_Callback() {  // Login to xmlBlaster, register for updates
               public String update(String cbSessionId, UpdateKey updateKey, byte[] content, UpdateQos updateQos) {
                  log.severe("Receive message '" + updateKey.getOid() + "'");
                  assertInUpdate = serverHelper.getHeronGlob().getId() + ": Did not expect message update in default handler";
                  fail(assertInUpdate); // This is routed to server, not to junit
                  return "";
               }
            });
         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 ...
         pk = new PublishKey(glob, oid, "text/plain", "1.0");
         pk.setDomain(domain);
         pq = new PublishQos(glob);
         msgUnit = new MsgUnit(pk.toXml(), contentStr.getBytes(), pq.toXml());
         prq = bilboCon.publish(msgUnit);
         log.info("Published message of domain='" + pk.getDomain() + "' and content='" + contentStr +
                                    "' to xmlBlaster node bilbo with IP=" + serverHelper.getBilboGlob().getProperty().get("bootstrapPort",0) +
                                    ", the returned QoS is: " + prq.getKeyOid());


         assertEquals("heron is not reachable, publish should not have come through", 0, updateCounterHeron);

         serverHelper.startFrodo();

         try { Thread.sleep(1000); } catch( InterruptedException i) {} // Wait some time
         assertEquals("heron has not received message", 1, updateCounterHeron);
         updateCounterHeron = 0;

         System.err.println("->Connect to frodo ...");
         frodoCon = serverHelper.connect(serverHelper.getFrodoGlob(), new I_Callback() {
               public String update(String cbSessionId, UpdateKey updateKey, byte[] content, UpdateQos updateQos) {
                  assertInUpdate = serverHelper.getFrodoGlob().getId() + ": Receive unexpected message '" + updateKey.getOid() + "'";
                  return "";
               }
            });
         try { Thread.sleep(1000); } catch( InterruptedException i) {} // Wait some time
         assertTrue(assertInUpdate, assertInUpdate == null);
         assertInUpdate = null;

         System.err.println("->Subscribe from frodo, is he able to organize it?");
         sk = new SubscribeKey(glob, oid);
         sk.setDomain(domain);
         sq = new SubscribeQos(glob);
         srq = frodoCon.subscribe(sk.toXml(), sq.toXml(), new I_Callback() {
            public String update(String cbSessionId, UpdateKey updateKey, byte[] content, UpdateQos updateQos) {
               log.info("frodoCon - Receiving asynchronous message '" + updateKey.getOid() + "' in " + oid + " handler, state=" + updateQos.getState());
               updateCounterFrodo++;
               assertInUpdate = null;
               return "";
View Full Code Here

TOP

Related Classes of org.xmlBlaster.client.I_Callback

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.