本文整理了Java中kafka.message.Message.isValid()
方法的一些代码示例,展示了Message.isValid()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.isValid()
方法的具体详情如下:
包路径:kafka.message.Message
类名称: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;
}
内容来源于网络,如有侵权,请联系作者删除!