Exemplo n.º 1
0
  /**
   * Dispatches a message to the appropriate receiver.
   *
   * <p>It will buffer the message under the following conditions: 1) The MessageReceiver is not yet
   * registered. 2) The MessageReceiver is a PastryAppl, and localNode.isReady() == false
   *
   * @param msg the message.
   * @return true if message could be dispatched, false otherwise.
   */
  public boolean dispatchMessage(Message msg) {
    if (msg.getDestination() == 0) {
      Logger logger =
          localNode.getEnvironment().getLogManager().getLogger(MessageDispatch.class, null);
      if (logger.level <= Logger.WARNING)
        logger.logException(
            "Message " + msg + "," + msg.getClass().getName() + " has no destination.",
            new Exception("Stack Trace"));
      return false;
    }
    // NOTE: There is no safety issue with calling localNode.isReady() because this is on the
    // PastryThread, and the only way to set a node ready is also on the ready thread.
    PastryAppl mr = (PastryAppl) addressBook.get(Integer.valueOf(msg.getDestination()));

    if (mr == null) {
      if ((logger.level <= Logger.FINE) || (localNode.isReady() && (logger.level <= Logger.INFO))) {
        logger.log(
            "Dropping message "
                + msg
                + " because the application address "
                + msg.getDestination()
                + " is unknown.");
      }
      return false;
    } else {
      mr.receiveMessage(msg);
      return true;
    }
  }
Exemplo n.º 2
0
 protected final void logMessage(final Message message) {
   final BotEvent event = message.getEvent();
   final String sender = getNick();
   final String channel = event.getChannel();
   if (!channel.equals(sender)) {
     if (channelDao.isLogged(channel)) {
       logsDao.logMessage(
           Logs.Type.MESSAGE, sender, message.getDestination(), message.getMessage());
     }
   }
 }
Exemplo n.º 3
0
 private void logSend(Message copy) {
   Logger perDestinationsLogger = LOG;
   if (isPerDestinationLogger()) {
     ActiveMQDestination destination = copy.getDestination();
     perDestinationsLogger =
         LoggerFactory.getLogger(
             LOG.getName()
                 + "."
                 + destination.getDestinationTypeAsString()
                 + "."
                 + destination.getPhysicalName());
   }
   perDestinationsLogger.info("Sending message: {}", copy);
 }
 public boolean unicast(Message m) {
   boolean drop = false;
   drop = (m.getDestination() == pid && !Utils.SELFMSGENABLED);
   if (!drop) return await(m.pack()); /* write(m.pack()); */
   return false;
 }
Exemplo n.º 5
0
 void postAction(final Message message) {
   sendAction(message.getDestination(), message.getMessage());
   logMessage(message);
 }
Exemplo n.º 6
0
 public PastryAppl getDestination(Message msg) {
   return getDestinationByAddress(msg.getDestination());
 }