Package org.xmlBlaster.client.qos

Examples of org.xmlBlaster.client.qos.ConnectReturnQos


         connectQos.loadClientPlugin("htpasswd", "1.0", loginName, passwd);
         connectQos.getSessionQos().setSessionTimeout(0L);
         // TODO: Port to use "LOCAL" protocol to connect
         this.addressServer = new AddressServer(authenticate.getGlobal(), "NATIVE", authenticate.getGlobal().getId(), (java.util.Properties)null);
         String ret = authenticate.connect(addressServer, connectQos.toXml(), null); // synchronous access only, no callback.
         ConnectReturnQos retQos = new ConnectReturnQos(authenticate.getGlobal(), ret);
         this.secretSessionId = retQos.getSecretSessionId();
         log.info("login for '" + loginName + "' successful.");
      }
View Full Code Here


      try {

         log.info("============ STEP 1: Start publisher");
         conSnd = glob.getXmlBlasterAccess();
         ConnectQos qosPub = new ConnectQos(glob);
         ConnectReturnQos crqPub = conSnd.connect(qosPub, null)// Login to xmlBlaster, no updates
         log.info("Connect success as " + crqPub.getSessionName());

         int numPub = 8;
         log.info("============ STEP 2: Publish " + numPub + " PtP messages");
         MsgUnit[] sentArr = new MsgUnit[numPub];
         PublishReturnQos[] sentQos = new PublishReturnQos[numPub];
         for(int i=0; i<numPub; i++) {
            PublishKey pk = new PublishKey(glob, oid, "text/xml", "1.0");
            pk.setClientTags("<org.xmlBlaster><demo/></org.xmlBlaster>");
           
            PublishQos pq = new PublishQos(glob);
            pq.setPriority(PriorityEnum.NORM_PRIORITY);
            pq.setPersistent(true);
            Destination dest = new Destination(glob, new SessionName(glob, sessionNameRcv));
            dest.forceQueuing(true);
            pq.addDestination(dest);
            pq.setForceUpdate(true);
            pq.setSubscribable(false);
            pq.setLifeTime(60000L);
           
            if (i == 0) {
               TopicProperty topicProperty = new TopicProperty(glob);
               topicProperty.setDestroyDelay(60000L);
               topicProperty.setCreateDomEntry(true);
               topicProperty.setReadonly(false);
               topicProperty.getHistoryQueueProperty().setMaxEntries(numPub+5);
               pq.setTopicProperty(topicProperty);
               log.info("Added TopicProperty on first publish: " + topicProperty.toXml());
            }

            byte[] content = "Hello".getBytes();
            MsgUnit msgUnit = new MsgUnit(pk, content, pq);
            sentArr[i] = msgUnit;
            PublishReturnQos prq = conSnd.publish(msgUnit);
            sentQos[i] = prq;
            log.info("Got status='" + prq.getState() + "' rcvTimestamp=" + prq.getRcvTimestamp().toString() +
                        " for published message '" + prq.getKeyOid() + "'");
         }

         log.info("============ STEP 3: Stop xmlBlaster");
         this.serverThread.stopServer(true);

         log.info("============ STEP 4: Start xmlBlaster");
         glob.init(Util.getOtherServerPorts(serverPort));
         serverThread = EmbeddedXmlBlaster.startXmlBlaster(glob);
         log.info("XmlBlaster is ready for testing");

         log.info("============ STEP 5: Start subscriber");
         // A testsuite helper to collect update messages
         this.updateInterceptorRcv = new MsgInterceptor(glob, log, null);

         Global globRcv = glob.getClone(null);
         conRcv = globRcv.getXmlBlasterAccess();
        
         ConnectQos qosSub = new ConnectQos(globRcv, sessionNameRcv, passwd);

         CallbackAddress addr = new CallbackAddress(globRcv);
         addr.setRetries(-1);
         String secretCbSessionId = "TrustMeSub";
         addr.setSecretCbSessionId(secretCbSessionId);
         qosSub.getSessionCbQueueProperty().setCallbackAddress(addr);

         ConnectReturnQos crqSub = conRcv.connect(qosSub, this.updateInterceptorRcv); // Login to xmlBlaster
         log.info("Connect as subscriber '" + crqSub.getSessionName() + "' success");

         SubscribeKey sk = new SubscribeKey(globRcv, oid);
         SubscribeQos sq = new SubscribeQos(globRcv);
         sq.setWantInitialUpdate(false);
         sq.setWantLocal(true);
View Full Code Here

         String secretSndCbSessionId = "TrustMeSubSnd";
         CallbackAddress addrSnd = new CallbackAddress(globSnd);
         addrSnd.setSecretCbSessionId(secretSndCbSessionId);
         qosSnd.getSessionCbQueueProperty().setCallbackAddress(addrSnd);
         this.updateInterceptorSnd = new MsgInterceptor(globSnd, log, null);
         ConnectReturnQos crqPub = conSnd.connect(qosSnd, this.updateInterceptorSnd);
         log.info("Connect success as " + crqPub.getSessionName());

         log.info("============ STEP 2: Subscribe in Pub/Sub mode");
         SubscribeKey sk = new SubscribeKey(globSnd, oid);
         SubscribeQos sq = new SubscribeQos(globSnd);
         sq.setWantInitialUpdate(false);
         sq.setWantLocal(true);
         SubscribeReturnQos srq = conSnd.subscribe(sk, sq);
         log.info("Subscription to '" + oid + "' done");
         assertEquals("", 0, this.updateInterceptorSnd.waitOnUpdate(1000L, oid, Constants.STATE_OK));

         log.info("============ STEP 3: Start receiver");
         Global globRcv = glob.getClone(null);
         conRcv = globRcv.getXmlBlasterAccess();
         ConnectQos qosRcv = new ConnectQos(globRcv, sessionNameRcv, passwd);
         CallbackAddress addr = new CallbackAddress(globRcv);
         addr.setRetries(-1);
         String secretCbSessionId = "TrustMeSub";
         addr.setSecretCbSessionId(secretCbSessionId);
         qosRcv.getSessionCbQueueProperty().setCallbackAddress(addr);
         this.updateInterceptorRcv = new MsgInterceptor(globRcv, log, null);
         ConnectReturnQos crqRcv = conRcv.connect(qosRcv, this.updateInterceptorRcv); // Login to xmlBlaster
         log.info("Connect as subscriber '" + crqRcv.getSessionName() + "' success");

         {
            log.info("============ STEP 4: Publish PtP message which is NOT subscribable");
            PublishKey pk = new PublishKey(globSnd, oid, "text/xml", "1.0");
            PublishQos pq = new PublishQos(globSnd);
View Full Code Here

         ConnectQos qos = new ConnectQos(clonedGlob, user,pwd);
         qos.setPtpAllowed(false);
        
         System.out.println("Physical pipe: " + physicalPipe+"/CQos:"+qos);
        
         ConnectReturnQos ret = physicalPipe.connect(qos,null);
         me = "BlasterManagedConnection/"+user+"/"+ret.getSecretSessionId();
        
      }catch(XmlBlasterException ex) {
         throw new CommException("Could not login : " +ex);
      }
     
View Full Code Here

         // setup the sender client ...
            sender = glob.getXmlBlasterAccess();

            ConnectQos qos = new ConnectQos(sender.getGlobal(), senderName, "secret");
            ConnectReturnQos conRetQos = sender.connect(qos, null); // Login to xmlBlaster

            log.info("Sender connected to xmlBlaster " + conRetQos.getSessionName().getRelativeName());
         }


         {  // 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 "";
                  if (updateQos.isErased()) return "";
                  try {
                     String tempTopicOid = updateQos.getClientProperty(Constants.JMS_REPLY_TO, ""); // __jms:JMSReplyTo
                     log.info(receiverName+": Got request, using topic '" + tempTopicOid + "' for response");

                     // Send reply back ...
                     PublishKey pk = new PublishKey(receiver.getGlobal(), tempTopicOid, "text/plain", "1.0");
                     PublishQos pq = new PublishQos(receiver.getGlobal());
                     MsgUnit msgUnit = new MsgUnit(pk, "On doubt no ultimate truth, my dear.", pq);
                     //try { Thread.sleep(8000); } catch (InterruptedException e) { e.printStackTrace(); }
                     PublishReturnQos retQos = receiver.publish(msgUnit);
                     log.info(receiverName+": Published reply message using temporary topic " + retQos.getKeyOid());
                  }
                  catch (XmlBlasterException e) {
                     log.severe(receiverName+": Sending reply to " + updateQos.getSender() + " failed: " + e.getMessage());
                  }
                  return "";
               }
            })// Login to xmlBlaster, default handler for updates

            log.info("Receiver connected to xmlBlaster " + conRetQos.getSessionName().getRelativeName());
         }

         // Send a message to 'receiver' and block for the reply
         PublishKey pk = new PublishKey(sender.getGlobal(), "requestForEnlightenment");
         PublishQos pq = new PublishQos(sender.getGlobal());
View Full Code Here

               String key = (String)it.next();
               qos.addClientProperty(key, connectQosClientPropertyMap.get(key).toString());
            }
         }
         log.info("ConnectQos is " + qos.toXml());
         ConnectReturnQos crq = con.connect(qos, new I_Callback() {
      public String update(String cbSessionId, UpdateKey updateKey, byte[] content, UpdateQos updateQos) throws XmlBlasterException {
        try {
          log.info("Received '" + updateKey.getOid() + "':" + new String(content, "UTF-8"));
        } catch (UnsupportedEncodingException e) {
          log.severe("Update failed: " + e.toString());
        }
        return "";
      }
         })// Login to xmlBlaster, register for updates
         log.info("Connect success as " + crq.toXml());

         org.xmlBlaster.util.StopWatch stopWatch = new org.xmlBlaster.util.StopWatch();
         for(int i=0; true; i++) {
            if (numPublish != -1)
               if (i>=numPublish)
View Full Code Here

         I_XmlBlasterAccess con = glob.getXmlBlasterAccess();
         log.info("============= CreatingConnectQos");
         ConnectQos qos = new ConnectQos(glob);
         log.info("ConnectQos is " + qos.toXml());
         ConnectReturnQos crq = con.connect(qos, null)// Login to xmlBlaster, register for updates
         log.info("Connect success as " + crq.toXml());

         if (interactive) {
            log.info("Hit a key to erase");
            try { System.in.read(); } catch(java.io.IOException e) {}
         }
View Full Code Here

               String key = (String)it.next();
               qos.addClientProperty(key, connectQosClientPropertyMap.get(key).toString());
            }
         }
         log.info("ConnectQos is " + qos.toXml());
         ConnectReturnQos crq = con.connect(qos, null)// Login to xmlBlaster
         log.info("Connect success as " + crq.toXml());
        
         MsgUnit[] msgs = null;
         if (queryOid != null) {
            // http://www.xmlblaster.org/xmlBlaster/doc/requirements/engine.qos.queryspec.QueueQuery.html
            if (interactive) {
View Full Code Here

         // setup the sender client ...
            sender = glob.getXmlBlasterAccess();

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

            log.info("Sender connected to xmlBlaster " + conRetQos.getSessionName().getRelativeName());
         }


         {  // setup the receiver client ...
            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("Receiving asynchronous message '" + updateKey.getOid() + "' in receiver default handler");
                  log.info("Received: " + updateKey.toXml() + "\n <content>" + new String(content) + "</content>" + updateQos.toXml());

                  if (updateKey.isInternal()) return "";
                  if (updateQos.isErased()) return "";
                  try {
                     // Send an ACK back ...
                     PublishKey pk = new PublishKey(receiver.getGlobal(), "HelloWorld5:ACK", "text/plain", "1.0");
                     PublishQos pq = new PublishQos(receiver.getGlobal());
                     pq.addDestination(new Destination(updateQos.getSender()));
                     MsgUnit msgUnit = new MsgUnit(pk, "ACK", pq);
                     boolean oneway = false; // just for demo, you can try a variant with never blocking oneway
                     if (oneway) {
                        MsgUnit[] arr = new MsgUnit[1];
                        arr[0] = msgUnit;
                        receiver.publishOneway(arr);
                        log.info("Published message '" + pk.getOid() + "' to " + updateQos.getSender());
                     }
                     else {
                        PublishReturnQos retQos = receiver.publish(msgUnit);
                        log.info("Published message '" + retQos.getKeyOid() + "' to " + updateQos.getSender());
                     }
                  }
                  catch (XmlBlasterException e) {
                     log.severe("Sending ACK to " + updateQos.getSender() + " failed: " + e.getMessage());
                  }
                  return "";
               }
            })// Login to xmlBlaster, default handler for updates

            log.info("Receiver connected to xmlBlaster " + conRetQos.getSessionName().getRelativeName());
         }

         // Send a message to 'receiver'
         PublishKey pk = new PublishKey(sender.getGlobal(), "HelloWorld5", "text/plain", "1.0");
         PublishQos pq = new PublishQos(sender.getGlobal());
View Full Code Here

               // We don't need those pings as the other side is responsible to take care on the socket connection
               connectQos.getSessionCbQueueProperty().getCurrentCallbackAddress().setPingInterval(0L);
               connectQos.getAddress().setPingInterval(0L);
            }

            ConnectReturnQos retQos = this.xmlBlasterConnection.connect(connectQos, this);
           
            if (log.isLoggable(Level.FINE)) log.fine("Connected to server " + retQos.getServerInstanceId());
         }
         catch(XmlBlasterException e) {
            if (e.isInternal()) {
               log.severe("Connecting to " + getId() + " is not possible: " + e.getMessage());
            }
View Full Code Here

TOP

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

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.