Package org.xmlBlaster.engine.queuemsg

Examples of org.xmlBlaster.engine.queuemsg.MsgQueueUpdateEntry


    */
   public final long forwardToSessionQueue() {
      if (getSessions().length < 1 || this.subjectQueue.getNumOfEntries() < 1) return 0;

      long numMsgs = 0;
      MsgQueueUpdateEntry entry = null;
      if (log.isLoggable(Level.FINE)) log.fine(ME+": Trying to forward " + this.subjectQueue.getNumOfEntries() + " messages in subject queue to session queue ...");
      while (true) {
         try {
            try {
               entry = (MsgQueueUpdateEntry)this.subjectQueue.peek(); // non-blocking
            }
            catch (Throwable ex) {
               log.severe(ME+": Can't get entry from subject queue when trying to forward it to session queue " + ex.getMessage());
               // TODO toDead from the subject may be necessary to avoid looping
               break;
            }
            if (entry == null)
               break;
            if (entry.isDestroyed()) {
               log.info(ME+": Message " + entry.getLogId() + " is destroyed, ignoring it");
               this.subjectQueue.removeRandom(entry); // Remove the destroyed entry
            }
            else {
               int countForwarded = forwardToSessionQueue(entry);
               if (countForwarded > 0) {
                  this.subjectQueue.removeRandom(entry); // Remove the forwarded entry (blocking)
                  numMsgs++;
               }
               else if (countForwarded == -1) { // There are sessions but they don't want PtP
                  break;
               }
            }
         }
         catch(Throwable e) {
            MsgQueueEntry[] msgQueueEntries = new MsgQueueEntry[] { entry };
            MsgErrorInfo msgErrorInfo = new MsgErrorInfo(glob, msgQueueEntries, null, e)// this.subjectQueue
            getMsgErrorHandler().handleError(msgErrorInfo);

            try {
               this.subjectQueue.removeRandom(entry); // Remove the entry
            }
            catch (XmlBlasterException ex) {
               log.severe(ME+": Can't empty queue when removing '" + entry.getLogId() + "' " + ex.getMessage());
               // TODO toDead from the subject may be necessary to avoid looping
               break;
            }
         }
      }
View Full Code Here


            if (log.isLoggable(Level.FINE)) log.fine(ME+": Forwarding msg " + entry.getLogId() + " from " +
                          this.subjectQueue.getStorageId() + " size=" + this.subjectQueue.getNumOfEntries() +
                          " to session queue " + sessionQueue.getStorageId() +
                          " size=" + sessionQueue.getNumOfEntries() + " ...");
            try {
               MsgQueueUpdateEntry entryCb = new MsgQueueUpdateEntry((MsgQueueUpdateEntry)entry, sessionQueue.getStorageId());
               sessionInfo.queueMessage(entryCb);
               countForwarded++;
            }
            catch (XmlBlasterException e) {
               if (log.isLoggable(Level.FINE)) log.fine(ME+": Can't forward message from subject queue '" + this.subjectQueue.getStorageId() + "' to session '" + sessionInfo.getId() + "', we keep it in the subject queue: " + e.getMessage());
View Full Code Here

TOP

Related Classes of org.xmlBlaster.engine.queuemsg.MsgQueueUpdateEntry

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.