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

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

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

Message.getPublishTime介绍

[英]Return the time when the message is published
[中]返回消息发布的时间

代码示例

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

/**
 * Gets publication time of this message in Unix time format.
 *
 * @return Publication time of this message in Unix time format.
 */
@Override
public long getTimeStamp() {
  return hzMessage.getPublishTime();
}

代码示例来源: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: 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);
    }
  }
}

相关文章