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

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

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

Message.size介绍

暂无

代码示例

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

public Kafka08ConsumerRecord(MessageAndOffset messageAndOffset) {
 super(messageAndOffset.offset(), messageAndOffset.message().size());
 this.messageAndOffset = messageAndOffset;
}

代码示例来源:origin: linkedin/camus

/**
 * Fetches the next Kafka message and stuffs the results into the key and
 * value
 *
 * @param etlKey
 * @return true if there exists more events
 * @throws IOException
 */
public KafkaMessage getNext(EtlKey etlKey) throws IOException {
 if (hasNext()) {
  MessageAndOffset msgAndOffset = messageIter.next();
  Message message = msgAndOffset.message();
  byte[] payload = getBytes(message.payload());
  byte[] key = getBytes(message.key());
  if (payload == null) {
   log.warn("Received message with null message.payload(): " + msgAndOffset);
  }
  etlKey.clear();
  etlKey.set(kafkaRequest.getTopic(), kafkaRequest.getLeaderId(), kafkaRequest.getPartition(), currentOffset,
    msgAndOffset.offset() + 1, message.checksum());
  etlKey.setMessageSize(msgAndOffset.message().size());
  currentOffset = msgAndOffset.offset() + 1; // increase offset
  currentCount++; // increase count
  return new KafkaMessage(payload, key, kafkaRequest.getTopic(), kafkaRequest.getPartition(),
    msgAndOffset.offset(), message.checksum());
 } else {
  return null;
 }
}

代码示例来源:origin: com.linkedin.gobblin/gobblin-kafka-08

public Kafka08ConsumerRecord(MessageAndOffset messageAndOffset) {
 super(messageAndOffset.offset(), messageAndOffset.message().size());
 this.messageAndOffset = messageAndOffset;
}

代码示例来源:origin: org.apache.gobblin/gobblin-kafka-08

public Kafka08ConsumerRecord(MessageAndOffset messageAndOffset) {
 super(messageAndOffset.offset(), messageAndOffset.message().size());
 this.messageAndOffset = messageAndOffset;
}

代码示例来源:origin: apache/apex-malhar

if ((emitCount > 0) && ((maxTotalMsgSizePerWindow - emitTotalMsgSize) < message.msg.size())) {
 pendingMessage = message;
 break;
emitTotalMsgSize += message.msg.size();
offsetStats.put(message.kafkaPart, message.offSet);
MutablePair<Long, Integer> offsetAndCount = currentWindowRecoveryState.get(message.kafkaPart);

代码示例来源:origin: org.apache.apex/malhar-contrib

if ((emitCount > 0) && ((maxTotalMsgSizePerWindow - emitTotalMsgSize) < message.msg.size())) {
 pendingMessage = message;
 break;
emitTotalMsgSize += message.msg.size();
offsetStats.put(message.kafkaPart, message.offSet);
MutablePair<Long, Integer> offsetAndCount = currentWindowRecoveryState.get(message.kafkaPart);

代码示例来源:origin: HiveKa/HiveKa

msgAndOffset.offset() + 1, message.checksum());
key.setMessageSize(msgAndOffset.message().size());

代码示例来源:origin: com.linkedin.camus/camus-etl-kafka

/**
 * Fetches the next Kafka message and stuffs the results into the key and
 * value
 *
 * @param etlKey
 * @return true if there exists more events
 * @throws IOException
 */
public KafkaMessage getNext(EtlKey etlKey) throws IOException {
 if (hasNext()) {
  MessageAndOffset msgAndOffset = messageIter.next();
  Message message = msgAndOffset.message();
  byte[] payload = getBytes(message.payload());
  byte[] key = getBytes(message.key());
  if (payload == null) {
   log.warn("Received message with null message.payload(): " + msgAndOffset);
  }
  etlKey.clear();
  etlKey.set(kafkaRequest.getTopic(), kafkaRequest.getLeaderId(), kafkaRequest.getPartition(), currentOffset,
    msgAndOffset.offset() + 1, message.checksum());
  etlKey.setMessageSize(msgAndOffset.message().size());
  currentOffset = msgAndOffset.offset() + 1; // increase offset
  currentCount++; // increase count
  return new KafkaMessage(payload, key, kafkaRequest.getTopic(), kafkaRequest.getPartition(),
    msgAndOffset.offset(), message.checksum());
 } else {
  return null;
 }
}

相关文章