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

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

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

Message.hasKey介绍

暂无

代码示例

代码示例来源:origin: pinterest/secor

topicPartition.getTopic(), topicPartition.getPartition()).iterator().next();
byte[] keyBytes = null;
if (messageAndOffset.message().hasKey()) {
  ByteBuffer key = messageAndOffset.message().key();
  keyBytes = new byte[key.limit()];

代码示例来源:origin: com.github.hackerwin7/jlib-utils

val = valBytes;
if(messageAndOffset.message().hasKey()) {
  ByteBuffer keyBuffer = messageAndOffset.message().key();
  byte[] keyBytes = new byte[keyBuffer.limit()];

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

相关文章