kafka.message.Message.isValid()方法的使用及代码示例

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

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

Message.isValid介绍

暂无

代码示例

代码示例来源:origin: apache/incubator-pinot

private Iterable<MessageAndOffset> buildOffsetFilteringIterable(final ByteBufferMessageSet messageAndOffsets,
  final long startOffset, final long endOffset) {
 return Iterables.filter(messageAndOffsets, input -> {
  // Filter messages that are either null or have an offset ∉ [startOffset; endOffset[
  if (input == null || input.offset() < startOffset || (endOffset <= input.offset() && endOffset != -1)) {
   return false;
  }
  // Check the message's checksum
  // TODO We might want to have better handling of this situation, maybe try to fetch the message again?
  if (!input.message().isValid()) {
   LOGGER.warn("Discarded message with invalid checksum in partition {} of topic {}", _partition, _topic);
   return false;
  }
  return true;
 });
}

代码示例来源:origin: HomeAdvisor/Kafdrop

private MessageVO createMessage(Message message, MessageDeserializer deserializer)
{
 MessageVO vo = new MessageVO();
 if (message.hasKey())
 {
   vo.setKey(ByteUtils.readString(message.key()));
 }
 if (!message.isNull())
 {
   final String messageString = deserializer.deserializeMessage(message.payload());
   vo.setMessage(messageString);
 }
 vo.setValid(message.isValid());
 vo.setCompressionCodec(message.compressionCodec().name());
 vo.setChecksum(message.checksum());
 vo.setComputedChecksum(message.computeChecksum());
 return vo;
}

相关文章