com.hazelcast.core.Message.getPublishingMember()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(6.4k)|赞(0)|评价(0)|浏览(143)

本文整理了Java中com.hazelcast.core.Message.getPublishingMember()方法的一些代码示例,展示了Message.getPublishingMember()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.getPublishingMember()方法的具体详情如下:
包路径:com.hazelcast.core.Message
类名称:Message
方法名:getPublishingMember

Message.getPublishingMember介绍

[英]Returns the member that published the message. It can be that the member is null if:

  1. the message was send by a client and not a member
  2. the member that send the message, left the cluster before the message was processed.
    [中]返回发布消息的成员。如果出现以下情况,则该成员可能为空:
    1.该消息是由客户端而非成员发送的
    1.发送消息的成员在处理消息之前离开了群集。

代码示例

代码示例来源:origin: spring-projects/spring-integration-extensions

@Override
protected void processEvent(Message<E> event) {
  sendMessage(event, event.getPublishingMember().getSocketAddress(), getCacheListeningPolicy());
  if (logger.isDebugEnabled()) {
    logger.debug("Received Message : " + event);
  }
}

代码示例来源:origin: org.geoserver.community/gs-hz-cluster

@Override
  public void onMessage(Message<UUID> message) {
    UUID eventId = message.getMessageObject();
    AtomicInteger countDown = expectedAckCounters.get(eventId);
    if (countDown != null) {
      countDown.decrementAndGet();
      String originAddr = null;
      Member publishingMember = message.getPublishingMember();
      if (publishingMember != null) {
        InetSocketAddress socketAddress = publishingMember.getSocketAddress();
        if (socketAddress != null) {
          originAddr = addressString(socketAddress);
        }
      }
      LOGGER.finer(
          format("%s - Got ack on event %s from %s", nodeId(), eventId, originAddr));
    }
  }
}

代码示例来源:origin: com.atlassian.cache/atlassian-cache-hazelcast

@Override
public void onMessage(Message<ReferenceKey> message) {
  CachedReference<?> localReference = localReferenceRef.get();
  if (localReference == null)
  {
    // cache has been gc-d
    destroy();
    return;
  }
  if (!message.getPublishingMember().localMember())
  {
    localReference.reset();
  }
}

代码示例来源:origin: com.jtbdevelopment.core-games/games-hazelcast

@Override
 public void onMessage(final Message<ClusterMessage> message) {
  if (message != null && !message.getPublishingMember().localMember()) {
   ClusterMessage clusterMessage = message.getMessageObject();
   if (clusterMessage != null) {
    receiveClusterMessage(clusterMessage);
   }

  }

 }
}

代码示例来源:origin: spring-projects/spring-integration-extensions

@Override
protected org.springframework.messaging.Message<?> toMessage(Message<E> event) {
  Assert.notNull(event.getMessageObject(), "message must not be null");
  final Map<String, Object> headers = new HashMap<>();
  headers.put(HazelcastHeaders.MEMBER, event.getPublishingMember().getSocketAddress());
  headers.put(HazelcastHeaders.CACHE_NAME, event.getSource());
  headers.put(HazelcastHeaders.PUBLISHING_TIME, event.getPublishTime());
  return getMessageBuilderFactory().withPayload(event.getMessageObject()).copyHeaders(headers).build();
}

代码示例来源:origin: com.hazelcast/hazelcast-hibernate4

public void onMessage(final Message<Object> message) {
    if (!message.getPublishingMember().localMember()) {
      maybeInvalidate(message.getMessageObject());
    }
  }
};

代码示例来源:origin: io.snamp/internal-services

private static HazelcastNodeInfo getHazelcastNodeInfo(final Message<TransferObject> hzMessage){
  return new HazelcastNodeInfo(hzMessage.getPublishingMember(), hzMessage.getMessageObject().isSenderActive, hzMessage.getMessageObject().senderName);
}

代码示例来源:origin: com.atlassian.cache/atlassian-cache-hazelcast

@Override
public void onMessage(Message<K> message) {
  Cache<K, ?> localCache = localCacheRef.get();
  if (localCache == null)
  {
    // cache has been gc-d
    destroy();
    return;
  }
  if (!message.getPublishingMember().localMember())
  {
    K key = message.getMessageObject();
    if (key == null)
    {
      localCache.removeAll();
    }
    else
    {
      localCache.remove(key);
    }
  }
}

代码示例来源:origin: io.moquette/moquette-broker

@Override
  public void onMessage(Message<HazelcastMsg> msg) {
    ByteBuf payload = null;
    try {
      if (!msg.getPublishingMember().equals(server.getHazelcastInstance().getCluster().getLocalMember())) {
        HazelcastMsg hzMsg = msg.getMessageObject();
        LOG.info("{} received from hazelcast for topic {} message: {}", hzMsg.getClientId(), hzMsg.getTopic(),
          hzMsg.getPayload());
        // TODO pass forward this information in somehow publishMessage.setLocal(false);

        MqttQoS qos = MqttQoS.valueOf(hzMsg.getQos());
        MqttFixedHeader fixedHeader = new MqttFixedHeader(MqttMessageType.PUBLISH, false, qos, false, 0);
        MqttPublishVariableHeader varHeader = new MqttPublishVariableHeader(hzMsg.getTopic(), 0);
        payload = Unpooled.wrappedBuffer(hzMsg.getPayload());
        MqttPublishMessage publishMessage = new MqttPublishMessage(fixedHeader, varHeader, payload);
        server.internalPublish(publishMessage, hzMsg.getClientId());
      }
    } catch (Exception ex) {
      LOG.error("error polling hazelcast msg queue", ex);
    } finally {
      ReferenceCountUtil.release(payload);
    }
  }
}

代码示例来源:origin: hazelcast/hazelcast-jet

@Override
  public void onMessage(Message message) {
    if (!endpoint.isAlive()) {
      return;
    }

    if (!(message instanceof DataAwareMessage)) {
      throw new IllegalArgumentException("Expecting: DataAwareMessage, Found: "
          + message.getClass().getSimpleName());
    }

    DataAwareMessage dataAwareMessage = (DataAwareMessage) message;
    Data messageData = dataAwareMessage.getMessageData();
    String publisherUuid = message.getPublishingMember().getUuid();
    ClientMessage eventMessage = TopicAddMessageListenerCodec.encodeTopicEvent(messageData,
        message.getPublishTime(), publisherUuid);

    boolean isMultithreaded = nodeEngine.getConfig().findTopicConfig(parameters.name).isMultiThreadingEnabled();
    if (isMultithreaded) {
      int key = rand.nextInt();
      int partitionId = hashToIndex(key, nodeEngine.getPartitionService().getPartitionCount());
      eventMessage.setPartitionId(partitionId);
      sendClientMessage(eventMessage);
    } else {
      sendClientMessage(partitionKey, eventMessage);
    }
  }
}

代码示例来源:origin: com.hazelcast/hazelcast-all

@Override
  public void onMessage(Message message) {
    if (!endpoint.isAlive()) {
      return;
    }

    if (!(message instanceof DataAwareMessage)) {
      throw new IllegalArgumentException("Expecting: DataAwareMessage, Found: "
          + message.getClass().getSimpleName());
    }

    DataAwareMessage dataAwareMessage = (DataAwareMessage) message;
    Data messageData = dataAwareMessage.getMessageData();
    String publisherUuid = message.getPublishingMember().getUuid();
    ClientMessage eventMessage = TopicAddMessageListenerCodec.encodeTopicEvent(messageData,
        message.getPublishTime(), publisherUuid);

    boolean isMultithreaded = nodeEngine.getConfig().findTopicConfig(parameters.name).isMultiThreadingEnabled();
    if (isMultithreaded) {
      int key = rand.nextInt();
      int partitionId = hashToIndex(key, nodeEngine.getPartitionService().getPartitionCount());
      eventMessage.setPartitionId(partitionId);
      sendClientMessage(eventMessage);
    } else {
      sendClientMessage(partitionKey, eventMessage);
    }
  }
}

相关文章