public static void queueMessage(
      PlatformMessage message, PlatformMessengerListener listener, boolean addToBottom) {

    if (!initialized) {
      init();
    }

    if (message == null) {
      debug("fire timerevent");
    }
    queue_mon.enter();
    try {
      long fireBefore;
      String queueID = null;
      if (message != null) {
        long networkID = message.getContentNetworkID();
        if (networkID <= 0) {
          debug("Content Network invalid for " + message);
          return;
        }
        if (!message.sendAZID()) {
          queueID = QUEUE_NOAZID;
        } else {
          queueID = QUEUE_NORMAL;
        }
        queueID += networkID;

        Map<PlatformMessage, PlatformMessengerListener> mapQueue = (Map) mapQueues.get(queueID);
        if (mapQueue == null) {
          mapQueue = new LinkedHashMap<PlatformMessage, PlatformMessengerListener>();
          mapQueues.put(queueID, mapQueue);
        }
        mapQueue.put(message, listener);

        debug(
            "q "
                + queueID
                + "("
                + mapQueue.size()
                + ") "
                + message.toShortString()
                + ": "
                + message
                + " @ "
                + new Date(message.getFireBefore())
                + "; in "
                + (message.getFireBefore() - SystemTime.getCurrentTime())
                + "ms");

        fireBefore = message.getFireBefore();
      } else {
        fireBefore = SystemTime.getCurrentTime();
      }

      if (queueID != null) {
        try {
          mon_mapTimerEvents.enter();

          TimerEvent timerEvent = mapTimerEvents.get(queueID);

          if (timerEvent == null || timerEvent.hasRun() || fireBefore < timerEvent.getWhen()) {
            if (timerEvent != null) {
              mapTimerEvents.remove(timerEvent);
              timerEvent.cancel();
            }

            final String fQueueID = queueID;
            timerEvent =
                timerProcess.addEvent(
                    fireBefore,
                    new TimerEventPerformer() {
                      public void perform(TimerEvent event) {
                        try {
                          mon_mapTimerEvents.enter();

                          mapTimerEvents.remove(event);
                        } finally {
                          mon_mapTimerEvents.exit();
                        }

                        Map mapQueue = mapQueues.get(fQueueID);
                        while (mapQueue != null && mapQueue.size() > 0) {
                          processQueue(fQueueID, mapQueue);
                        }
                        /*
                        Object[] keys = mapQueues.keySet().toArray();
                        for (int i = 0; i < keys.length; i++) {
                        	Map mapQueue = mapQueues.get(keys[i]);
                        	while (mapQueue != null && mapQueue.size() > 0) {
                        		processQueue(mapQueue);
                        	}
                        }
                        */
                      }
                    });
            mapTimerEvents.put(queueID, timerEvent);
          }
          if (timerEvent != null) {
            debug(
                " next q process for  "
                    + queueID
                    + " in "
                    + (timerEvent.getWhen() - SystemTime.getCurrentTime()));
          }
        } finally {
          mon_mapTimerEvents.exit();
        }
      }
    } finally {
      queue_mon.exit();
    }
  }