Package org.xmlBlaster.client.qos

Examples of org.xmlBlaster.client.qos.PublishQos


                     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());
         pq.addDestination(new Destination(new SessionName(sender.getGlobal(), receiverName)));
         MsgUnit msgUnit = new MsgUnit(pk, "Tell me the truth!", pq);
         MsgUnit[] replies = sender.request(msgUnit, 6000, 1);
         if (replies.length > 0)
            log.info(senderName+": Got " + replies.length + " reply :\n" + replies[0].toXml());
         else
View Full Code Here


            }

            PublishKey pk = new PublishKey(glob, currOid, "text/xml", "1.0");
            if (domain != null) pk.setDomain(domain);
            pk.setClientTags(org.xmlBlaster.util.ReplaceVariable.replaceAll(clientTags, "%counter", currCounter));
            PublishQos pq = new PublishQos(glob);
            pq.setPriority(priority);
            pq.setPersistent(persistent);
            pq.setLifeTime(lifeTime);
            pq.setForceUpdate(forceUpdate);
            pq.setForceDestroy(forceDestroy);
            pq.setSubscribable(subscribable);
            if (clientPropertyMap != null) {
               Iterator it = clientPropertyMap.keySet().iterator();
               while (it.hasNext()) {
                  String key = (String)it.next();
                  pq.addClientProperty(key, clientPropertyMap.get(key).toString());
               }
               //Example for a typed property:
               //pq.getData().addClientProperty("ALONG", (new Long(12)));
            }

            if (i == 0) {
               TopicProperty topicProperty = new TopicProperty(glob);
               topicProperty.setDestroyDelay(destroyDelay);
               topicProperty.setCreateDomEntry(createDomEntry);
               topicProperty.setReadonly(readonly);
               if (historyMaxMsg >= 0L) {
                  HistoryQueueProperty prop = new HistoryQueueProperty(this.glob, null);
                  prop.setMaxEntries(historyMaxMsg);
                  topicProperty.setHistoryQueueProperty(prop);
               }
               if (consumableQueue)
                  topicProperty.setMsgDistributor("ConsumableQueue,1.0");
               pq.setTopicProperty(topicProperty);
               log.info("Added TopicProperty on first publish: " + topicProperty.toXml());
            }

            if (destination != null) {
               log.fine("Using destination: '" + destination + "'");
               Destination dest = new Destination(glob, new SessionName(glob, destination));
               dest.forceQueuing(forceQueuing);
               pq.addDestination(dest);
            }

            byte[] content;
            if (contentSize >= 0) {
               content = new byte[contentSize];
               Random random = new Random();
               for (int j=0; j<content.length; j++) {
                  content[j] = (byte)(random.nextInt(96)+32);
                  //content[j] = (byte)('X');
                  //content[j] = (byte)(j % 255);
               }
            }
            else if (contentFile != null && contentFile.length() > 0) {
               content = FileLocator.readFile(contentFile);
            }
            else {
               content = org.xmlBlaster.util.ReplaceVariable.replaceAll(contentStr, "%counter", ""+(i+1)).getBytes();
            }

            if (log.isLoggable(Level.FINEST)) log.finest("Going to parse publish message: " + pk.toXml() + " : " + content + " : " + pq.toXml());
            MsgUnit msgUnit = new MsgUnit(pk, content, pq);
            if (log.isLoggable(Level.FINEST)) log.finest("Going to publish message: " + msgUnit.toXml());

            if (oneway) {
               MsgUnit msgUnitArr[] = { msgUnit };
View Full Code Here

      if (this.publishOid == null)
         throw new XmlBlasterException(this.global, ErrorCode.USER_CLIENTCODE, ME, "no oid configured for publishing");
      if (content == null)
         throw new XmlBlasterException(this.global, ErrorCode.USER_CLIENTCODE, ME, "no content passed");
     
      PublishQos pubQos = new PublishQos(this.global);
      TopicProperty topicProp = new TopicProperty(this.global);
      topicProp.setMsgDistributor("ConsumableQueue,1.0");
      if (this.consumable) pubQos.setTopicProperty(topicProp);
      MsgUnit msgUnit = new MsgUnit(new PublishKey(this.global, this.publishOid), content, pubQos);
      this.accessor.publish(msgUnit);
   }
View Full Code Here

            }

         })// Login to xmlBlaster, default handler for updates

         String xmlKey = null;
         PublishQos qw = new PublishQos(glob);
         EraseQos eq = new EraseQos(glob);
         System.out.println("qos = " + qw.toXml() );
         byte[] b = new byte[1024];
         long lCount = 0L;
         while(true) {
            lCount++;
            xmlKey =  "<key oid='" + lCount +
                           "'> <topic id='aaaa'/>" +
                           "</key>";
            con.publish(new MsgUnit(xmlKey,b,qw.toXml()));

            try { Thread.sleep(5L); } catch( InterruptedException i) {}

            EraseKey ek = new EraseKey(glob, "" + lCount);
            EraseReturnQos[] er = con.erase(ek.toXml(), eq.toXml());
View Full Code Here

            }

         })// Login to xmlBlaster, default handler for updates

         String xmlKey = null;
         PublishQos qw = new PublishQos(glob);
         qw.setVolatile(true);
         System.out.println("qos = " + qw.toXml() );
         byte[] b = new byte[1024];
         while(true) {
            lCount++;
            xmlKey =  "<key oid='" + lCount +
                           "'> <topic id='aaaa'/>" +
                           "</key>";
            con.publish(new MsgUnit(xmlKey,b,qw.toXml()));
            // System.out.println(new Timestamp(System.currentTimeMillis())+":"+lCount);
            if ((lCount % bulkSize) == 0) {
               log.info("Sent " + lCount + " different topics, enter return to continue, enter 'q' to quit");
               try {
                  BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
View Full Code Here

            }

         })// Login to xmlBlaster, default handler for updates

         String xmlKey = null;
         PublishQos qw = new PublishQos(glob);
         System.out.println("qos = " + qw.toXml() );
         byte[] b = new byte[1024];
         while(true) {
            lCount++;
            xmlKey =  "<key oid='OneMessage'> <topic id='aaaa'/> </key>";
            con.publish(new MsgUnit(xmlKey,b,qw.toXml()));
            // System.out.println(new Timestamp(System.currentTimeMillis())+":"+lCount);
            if ((lCount % bulkSize) == 0) {
               try {
                  if (interactive) {
                     log.info("Sent " + lCount + " identical messages, enter return to continue, enter 'q' to quit");
View Full Code Here

         })// subscribe with our specific update handler
         log.info("Subsrcibed with id " + sr2.getSubscriptionId());


         PublishKey pk = new PublishKey(glob, "HelloWorld6", "text/plain", "1.0");
         PublishQos pq = new PublishQos(glob);
         MsgUnit msgUnit = new MsgUnit(pk, "Hi".getBytes(), pq);
         PublishReturnQos retQos = con.publish(msgUnit);
         log.info("Published message '" + pk.getOid() + "' " + retQos.getState());


         pk = new PublishKey(glob, "Banking", "text/plain", "1.0");
         pk.setClientTags("<Account><withdraw/></Account>"); // Add banking specific meta data
         pq = new PublishQos(glob);
         msgUnit = new MsgUnit(pk, "Ho".getBytes(), pq);
         con.publish(msgUnit);
         log.info("Published message '" + pk.getOid() + "'");
      }
      catch (XmlBlasterException e) {
View Full Code Here

         SubscribeQos sq = new SubscribeQos(glob);
         SubscribeReturnQos subRet = con.subscribe(sk, sq);

         // Publish a volatile message
         PublishKey pk = new PublishKey(glob, "HelloWorldVolatile2", "text/xml", "1.0");
         PublishQos pq = new PublishQos(glob);
         pq.setVolatile(true);
         // Configure the topic to our needs
         TopicProperty topicProperty = new TopicProperty(glob);
         topicProperty.setDestroyDelay(4000L);
         topicProperty.setCreateDomEntry(false);
         pq.setTopicProperty(topicProperty);
         MsgUnit msgUnit = new MsgUnit(pk, "Hi", pq);
         con.publish(msgUnit);

         // This should not be possible as the message was volatile
         try {
View Full Code Here

                  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());
         pq.addDestination(new Destination(new SessionName(sender.getGlobal(), receiverName)));
         MsgUnit msgUnit = new MsgUnit(pk, "Hi", pq);
         PublishReturnQos retQos = sender.publish(msgUnit);
         log.info("Published message '" + retQos.getKeyOid() + "' to " + receiverName + ":\n" + msgUnit.toXml());
      }
      catch (XmlBlasterException e) {
View Full Code Here

    */
   private void publishMessages() {
      try {

         PublishKey pk = new PublishKey(glob, "HelloWorld4", "text/plain", "1.0");
         PublishQos pq = new PublishQos(glob);
         MsgUnit msgUnit = new MsgUnit(pk, "Hi", pq);
         con.publish(msgUnit);
         log.info("Published message '" + pk.getOid() + "'");


         pk = new PublishKey(glob, "Banking", "text/plain", "1.0");
         pk.setClientTags("<Account><withdraw/></Account>"); // Add banking specific meta data
         pq = new PublishQos(glob);
         msgUnit = new MsgUnit(pk, "Ho".getBytes(), pq);
         con.publish(msgUnit);
         log.info("Published message '" + pk.getOid() + "'");

      }
View Full Code Here

TOP

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

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.