Package org.xmlBlaster.client.qos

Examples of org.xmlBlaster.client.qos.PublishQos


         throw new XBException("internal", "Convert: The passed 'msg' attribute is null.");
      // first strip all qos properties which are specific
      Destination dest = msg.getJMSDestination();
      if (!(dest instanceof XBDestination))
         throw new XBException("client.configuration", "destination is not an xmlblaster destination. Do not know how to handle it");
      PublishQos qos = null;
      PublishKey key = null;
      if (dest != null) {
         XBDestination xbDest = (XBDestination)dest;
         String ptpCompleteName = xbDest.getQueueName();
         if (ptpCompleteName != null) {
            String[] ptpNames = StringPairTokenizer.parseLine(ptpCompleteName, ',');
            org.xmlBlaster.util.qos.address.Destination ptpDest = new org.xmlBlaster.util.qos.address.Destination(global, new SessionName(global, ptpNames[0]));

            if (xbDest.getForceQueuing())
               ptpDest.forceQueuing(true);
            qos = new PublishQos(global, ptpDest);
            for (int i=1; i < ptpNames.length; i++) {
               org.xmlBlaster.util.qos.address.Destination additionalDest = new org.xmlBlaster.util.qos.address.Destination(global, new SessionName(global, ptpNames[i]));
               qos.addDestination(additionalDest);
            }
         }
         else {
            qos = new PublishQos(global);
         }
         String tmp = xbDest.getTopicName();
         if (tmp == null && ptpCompleteName == null)
            throw new XBException("client.configuration", "A Topic must be specified in the message to be sent");

         // determine if it is a complete key
         if (tmp != null && tmp.indexOf('<') > -1) { // complete key
            MsgKeySaxFactory keyFactory = new MsgKeySaxFactory(global);
            key = new PublishKey(global, keyFactory.readObject(tmp));
         }
         else { // then it is a simple oid
            if (tmp != null)
               key = new PublishKey(global, tmp);
            else
               key = new PublishKey(global);
         }
      }
      else
         throw new XBException("client.configuration", "A destination must be specified in the message to be sent");
      String corrId = msg.getJMSCorrelationID();
      if (corrId != null)
         qos.addClientProperty(XBMessage.addToKeyAndCheck(XBPropertyNames.JMS_CORRELATION_ID), corrId);
      int deliveryMode = msg.getJMSDeliveryMode();
      if (deliveryMode == DeliveryMode.PERSISTENT)
         qos.setPersistent(true);
      long expiration = msg.getJMSExpiration();
      if (expiration > -1)
         qos.setLifeTime(expiration);

      int prio = msg.getJMSPriority();
      if (prio > -1)
         qos.setPriority(PriorityEnum.toPriorityEnum(prio));
  
      String mimeType = msg.getJMSType(); // is this correct ?
      if (mimeType != null)
         key.setContentMime(mimeType);

      Enumeration eNum = msg.getPropertyNames();
      while (eNum.hasMoreElements()) {
         String propKey = (String)eNum.nextElement();
         Object obj = msg.getObjectProperty(propKey);
         qos.addClientProperty(XBMessage.addToKeyAndCheck(propKey), obj);
      }
      byte[] content = null;
      if (msg instanceof TextMessage) {
         qos.addClientProperty(XBMessage.addToKeyAndCheck(XBPropertyNames.JMS_MESSAGE_TYPE), XBMessage.TEXT);
         content = ((TextMessage)msg).getText().getBytes();
      }
      else if (msg instanceof StreamMessage) {
         qos.addClientProperty(XBMessage.addToKeyAndCheck(XBPropertyNames.JMS_MESSAGE_TYPE), XBMessage.STREAM);
         StreamMessage streamMsg = (StreamMessage)msg;
         if (streamMsg instanceof XBStreamMessage) {
            long length = ((XBStreamMessage)streamMsg).getBodyLength();
            if (length >= Integer.MAX_VALUE)
               throw new XBException("feature.missing", "Handling of big message not implemented");
            content = new byte[(int)length];
            streamMsg.readBytes(content);
         }
         else
            throw new XBException("feature.missing", "Handling of non XBStreamMessage types not implemented");
      }
      else if (msg instanceof BytesMessage) {
         qos.addClientProperty(XBMessage.addToKeyAndCheck(XBPropertyNames.JMS_MESSAGE_TYPE), XBMessage.BYTES);
         BytesMessage bytesMsg = (BytesMessage)msg;
         long length = bytesMsg.getBodyLength();
         if (length >= Integer.MAX_VALUE)
            throw new XBException("feature.missing", "Handling of big message not implemented");
         content = new byte[(int)length];
         bytesMsg.readBytes(content);
      }
      else if (msg instanceof ObjectMessage) {
         qos.addClientProperty(XBMessage.addToKeyAndCheck(XBPropertyNames.JMS_MESSAGE_TYPE), XBMessage.OBJECT);
         ObjectMessage objMsg = (ObjectMessage)msg;
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         ObjectOutputStream oos = new ObjectOutputStream(baos);
         Object object = objMsg.getObject();
         oos.writeObject(object);
View Full Code Here


      String cmd = ((isGet || isSet)) ? command.substring(4) : command;

      if (isSet || (!isGet && cmd.indexOf("=") != -1)) {
         String oid = "__cmd:" + cmd;
         PublishKey key = new PublishKey(glob, oid); // oid="__cmd:/client/joe/1/?dispatcherActive=false"
         PublishQos qos = new PublishQos(glob);
         MsgUnit msgUnit = new MsgUnit(key, "", qos);
         try {
            PublishReturnQos ret = publish(msgUnit);
            if (log.isLoggable(Level.FINE)) log.fine(getLogId()+"Send '" + cmd + " '");
            return ret.getState();
View Full Code Here

   public PublishReturnQos createTemporaryTopic(TopicProperty topicProperty) throws XmlBlasterException {
      if (topicProperty == null) {
         return createTemporaryTopic(-1, 10);
      }
      PublishKey pk = new PublishKey(glob, "");
      PublishQos pq = new PublishQos(glob);
      pq.setTopicProperty(topicProperty);
      MsgUnit msgUnit = new MsgUnit(pk, new byte[0], pq);
      PublishReturnQos prq = publish(msgUnit);
      if (log.isLoggable(Level.FINER)) log.finer(getLogId()+"Created temporary topic " + prq.getKeyOid());
      return prq;
   }
View Full Code Here

    * @throws XmlBlasterException
    */
   public PublishReturnQos createTemporaryTopic(String uniqueTopicId, long destroyDelay, int historyMaxMsg) throws XmlBlasterException {
    if (uniqueTopicId == null) uniqueTopicId = "";
      PublishKey pk = new PublishKey(glob, uniqueTopicId);
      PublishQos pq = new PublishQos(glob);
      TopicProperty topicProperty = new TopicProperty(glob);
      topicProperty.setDestroyDelay(destroyDelay);
      topicProperty.setCreateDomEntry(false);
      topicProperty.setReadonly(false);
      pq.setAdministrative(true);
      if (historyMaxMsg >= 0L) {
         HistoryQueueProperty prop = new HistoryQueueProperty(this.glob, null);
         prop.setMaxEntries(historyMaxMsg);
         topicProperty.setHistoryQueueProperty(prop);
      }
      pq.setTopicProperty(topicProperty);
      MsgUnit msgUnit = new MsgUnit(pk, new byte[0], pq);
      PublishReturnQos prq = publish(msgUnit);
      if (log.isLoggable(Level.FINER)) log.finer(getLogId()+"Created temporary topic " + prq.getKeyOid());
      return prq;
   }
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.