Ejemplo n.º 1
0
  /**
   * Hazelcast MessageListener implementation - called when a message is received from a cluster
   * node
   *
   * @param message Cluster message JSON string
   */
  @Override
  public void onMessage(final Message<String> message) {
    final boolean debug = logger.isDebugEnabled();

    // process message objects and extract the payload
    final String msg = message.getMessageObject();
    final MessageProcessor proc = new MessageProcessor(msg);
    if (!proc.isSender()) {
      if (debug) logger.debug("Received message of type:" + proc.getMessageType() + "\r\n" + msg);

      // call an implementation of a message handler bean
      final ClusterMessageAware bean = this.clusterBeans.get(proc.getMessageType());
      if (bean != null) {
        bean.onClusterMessage(proc.getMessagePayload());
      } else {
        logger.warn(
            "Received message of unknown type - no handler bean found: " + proc.getMessageType());
      }
    }
  }