Examples of XBSession


Examples of org.xmlBlaster.jms.XBSession

   /**
    * @see org.xmlBlaster.contrib.I_ChangePublisher#getJmsSession()
    */
   public XBSession getJmsSession() {
      return new XBSession(this.glob, XBSession.AUTO_ACKNOWLEDGE, false);
   }
View Full Code Here

Examples of org.xmlBlaster.jms.XBSession

         if (shortFilename == null)
            shortFilename = "noFileSinceNoInitialData";
         log.warning("The publisher has not been initialized, can not publish message for '" + shortFilename + "'");
         return;
      }
      XBSession session = this.publisher.getJmsSession();
      // XBMessageProducer producer = new XBMessageProducer(session, new XBDestination(topic, null));
     
      XBDestination dest = new XBDestination(this.initialDataTopic, SpecificDefault.toString(slaveSessionNames));
     
      XBMessageProducer producer = new XBMessageProducer(session, dest);
      producer.setPriority(PriorityEnum.HIGH_PRIORITY.getInt());
      producer.setDeliveryMode(DeliveryMode.PERSISTENT);
     
      String dumpId = "" + new Timestamp().getTimestamp();
      // now read the file which has been generated
      String filename = null;
      if (shortFilename != null) {
         log.info("sending initial file '" + shortFilename + "' for user '" + SpecificDefault.toString(slaveSessionNames+ "'");
         if (this.initialCmdPath != null)
            filename = this.initialCmdPath + File.separator + shortFilename;
         else
            filename = shortFilename;
         File file = new File(filename);
        
         FileInputStream fis = new FileInputStream(file);
        
         XBStreamingMessage msg = session.createStreamingMessage(this);
         msg.setIntProperty(XBConnectionMetaData.JMSX_MAX_CHUNK_SIZE, this.initialDumpMaxSize);
         msg.setStringProperty(FILENAME_ATTR, shortFilename);
         msg.setLongProperty(REPL_KEY_ATTR, minKey);
         msg.setStringProperty(DUMP_ACTION, "true");
         if (initialFilesLocation != null) {
            msg.setStringProperty(INITIAL_FILES_LOCATION, initialFilesLocation);
            msg.setStringProperty(INITIAL_DATA_ID, dumpId);
         }
         msg.setInputStream(fis);
         producer.send(msg);
         // make a version copy if none exists yet
         boolean doDelete = true;
         if (currentVersion != null) {
            String backupFileName = this.initialCmdPath + File.separator + VersionTransformerCache.buildFilename(this.replPrefix, currentVersion);
            File backupFile = new File(backupFileName);
            if (!backupFile.exists()) {
               final boolean copy = true;
               if (copy) {
                  BufferedInputStream bis = new BufferedInputStream(file.toURL().openStream());
                  FileOutputStream os = new FileOutputStream(backupFileName);
                  long length = file.length();
                  long remaining = length;
                  byte[] buf = new byte[this.initialDumpMaxSize];
                  while (remaining > 0) {
                     int tot = bis.read(buf);
                     remaining -= tot;
                     os.write(buf, 0, tot);
                  }
                  bis.close();
                  os.close();
               }
               else {
                  boolean ret = file.renameTo(backupFile);
                  if (!ret)
                     log.severe("could not move the file '" + filename + "' to '" + backupFileName + "' reason: could it be that the destination is not a local file system ? try the flag 'copyOnMove='true' (see http://www.xmlblaster.org/xmlBlaster/doc/requirements/client.filepoller.html");
                  else
                     doDelete = false;
               }
            }
         }
         else
            log.severe("The version is not set. Can not make a backup copy of the version file");
       
         boolean isRequestingCurrentVersion = currentVersion.equalsIgnoreCase(requestedVersion);
         if (!this.keepDumpFiles && doDelete && isRequestingCurrentVersion) {
            if (file.exists()) {
               boolean ret = file.delete();
               if (!ret)
                  log.warning("could not delete the file '" + filename + "'");
            }
         }
         fis.close();
      }
      else
         log.info("initial update requested with no real initial data for '" + SpecificDefault.toString(slaveSessionNames) + "' and for replication '" + this.replPrefix + "'");

      // send the message for the status change
      if (initialFilesLocation != null) {
         // then we save it in a file but we must tell it is finished now
         TextMessage  endMsg = session.createTextMessage();
         endMsg.setText("INITIAL UPDATE WILL BE STORED UNDER '" + initialFilesLocation + "'");
         endMsg.setBooleanProperty(INITIAL_DATA_END, true);
         endMsg.setStringProperty(INITIAL_DATA_ID, dumpId);
         endMsg.setStringProperty(INITIAL_FILES_LOCATION, initialFilesLocation);
         producer.send(endMsg);
         endMsg = session.createTextMessage();
         endMsg.setText("INITIAL UPDATE WILL BE STORED UNDER '" + initialFilesLocation + "' (going to remote)");
         endMsg.setBooleanProperty(INITIAL_DATA_END_TO_REMOTE, true);
         endMsg.setStringProperty(INITIAL_DATA_ID, dumpId);
         endMsg.setStringProperty(INITIAL_FILES_LOCATION, initialFilesLocation);
         producer.send(endMsg);
View Full Code Here

Examples of org.xmlBlaster.jms.XBSession

  
   /**
    * @see org.xmlBlaster.contrib.I_ChangePublisher#getJmsSession()
    */
   public XBSession getJmsSession() {
      return new XBSession(this.glob, XBSession.AUTO_ACKNOWLEDGE, false);
   }
View Full Code Here

Examples of org.xmlBlaster.jms.XBSession

      else
         log.warning("request for sending initial response can not be done since no publisher configured");
   }

   public void sendEndOfTransitionMessage(I_Info info, String initialDataTopic, String[] slaveSessionNames) throws JMSException {
      XBSession session = this.publisher.getJmsSession();
      XBDestination dest = new XBDestination(initialDataTopic, SpecificDefault.toString(slaveSessionNames));
      XBMessageProducer producer = new XBMessageProducer(session, dest);
      producer.setPriority(PriorityEnum.HIGH_PRIORITY.getInt());
      producer.setDeliveryMode(DeliveryMode.PERSISTENT);
      String dumpId = "" + new Timestamp().getTimestamp();
View Full Code Here

Examples of org.xmlBlaster.jms.XBSession

  
   private void doPublishJMS(byte[] content, int maxChunkSize, boolean doInterrupt, String name) throws JMSException {
      // Global glob = this.global.getClone(null);
      // XBSession session = new XBSession(this.publisherGlobal, XBSession.AUTO_ACKNOWLEDGE, false);
      log.info("Publishing for '" + name + "'");
      XBSession session = new XBSession(this.connGlobal, XBSession.AUTO_ACKNOWLEDGE, false);
      XBMessageProducer producer = new XBMessageProducer(session, new XBDestination(this.oid, null));
      producer.setDeliveryMode(DeliveryMode.PERSISTENT);
      XBStreamingMessage msg = session.createStreamingMessage(null);
      if (doInterrupt)
         msg.setBooleanProperty("interrupted", true);
      msg.setIntProperty(XBConnectionMetaData.JMSX_MAX_CHUNK_SIZE, maxChunkSize);
      msg.setStringProperty("nameOfTest", name); // to recognize it in '__sys__deadMessage'
      ByteArrayInputStream bais = new ByteArrayInputStream(content);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.