Package org.xmlBlaster.util

Examples of org.xmlBlaster.util.MsgUnit


         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


         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

         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

         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) {
         log.severe("Houston, we have a problem: " + e.toString());
View Full Code Here

         // 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 {
            GetKey gk = new GetKey(glob, "HelloWorldVolatile2");
View Full Code Here

                  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) {
         log.severe("Houston, we have a problem: " + e.getMessage());
      }
      finally {
View Full Code Here

         I_XmlBlasterAccess con = this.glob.getXmlBlasterAccess();

         ConnectQos qos = new ConnectQos(glob, "joe", "secret");
         con.connect(qos, null);

         con.publish(new MsgUnit("<key oid='__cmd:?exit=0'/>", "".getBytes(), "<qos/>"));

         con.disconnect(null);

         // xmlBlaster shuts down 2 sec later + time to process shutdown
         try { Thread.sleep(4000L); } catch( InterruptedException i) {}
View Full Code Here

             */
            public void postSend(MsgQueueEntry[] entries) {
               try {
                  for (int i=0; i<entries.length; i++) {
                     if (MethodName.PUBLISH.equals(entries[i].getMethodName())) {
                        MsgUnit msg = entries[i].getMsgUnit();
                        PublishReturnQos retQos = (PublishReturnQos)entries[i].getReturnObj();
                        log.info("Send asynchronously message '" + msg.getKeyOid() + "' from queue: " + retQos.toXml());
                     }
                     else
                        log.info("Send asynchronously " + entries[i].getMethodName() + " message from queue");
                  }
               } catch (Throwable e) {
                  e.printStackTrace();
               }
            }

            /**
             * @see I_PostSendListener#sendingFailed(MsgQueueEntry[], XmlBlasterException)
             */
            public boolean sendingFailed(MsgQueueEntry[] entries, XmlBlasterException ex) {
               try {
                  for (int i=0; i<entries.length; i++) {
                     if (MethodName.PUBLISH.equals(entries[i].getMethodName())) {
                        MsgUnit msg = entries[i].getMsgUnit();
                        log.info("Send asynchronously message '" + msg.getKeyOid() + "' from queue failed: " + ex.getMessage());
                     }
                     else
                        log.info("Send asynchronously " + entries[i].getMethodName() + " message from queue");
                  }
               } catch (Throwable 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() + "'");

      }
      catch (XmlBlasterException e) {
View Full Code Here

           
            msg.writeBytes(content, 0, content.length);
            XBDestination dest = new XBDestination("someTopic", null);
            msg.setJMSDestination(dest);
            msg.reset();
            MsgUnit msgUnit = MessageHelper.convertToMessageUnit(new Global(), msg);
           
            byte[] content2 = msgUnit.getContent();
            assertEquals("Wrong length", content.length, content2.length);
            msg.readBytes(content2);
            for (int i=0; i < content.length; i++)
               assertEquals("byte nr. '" + i + "' is wrong", content[i], content2[i]);
         }
View Full Code Here

TOP

Related Classes of org.xmlBlaster.util.MsgUnit

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.