本文整理了Java中kafka.message.Message.checksum()
方法的一些代码示例,展示了Message.checksum()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.checksum()
方法的具体详情如下:
包路径:kafka.message.Message
类名称:Message
方法名:checksum
暂无
代码示例来源:origin: linkedin/camus
public void validate() throws IOException {
// check the checksum of message.
Message readMessage;
if (key == null){
readMessage = new Message(payload);
} else {
readMessage = new Message(payload, key);
}
if (checksum != readMessage.checksum()) {
throw new ChecksumException("Invalid message checksum : " + readMessage.checksum() + ". Expected " + checksum,
offset);
}
}
代码示例来源: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.camus/camus-etl-kafka
public void validate() throws IOException {
// check the checksum of message.
Message readMessage;
if (key == null){
readMessage = new Message(payload);
} else {
readMessage = new Message(payload, key);
}
if (checksum != readMessage.checksum()) {
throw new ChecksumException("Invalid message checksum : " + readMessage.checksum() + ". Expected " + checksum,
offset);
}
}
代码示例来源:origin: HiveKa/HiveKa
key.set(kafkaRequest.getTopic(), kafkaRequest.getLeaderId(),
kafkaRequest.getPartition(), currentOffset,
msgAndOffset.offset() + 1, message.checksum());
代码示例来源:origin: HiveKa/HiveKa
Message messageWithoutKey = new Message(bytes);
long checksum = key.getChecksum();
if (checksum != messageWithKey.checksum() && checksum != messageWithoutKey.checksum()) {
throw new ChecksumException("Invalid message checksum : MessageWithKey : "
+ messageWithKey.checksum() + " MessageWithoutKey checksum : "
+ messageWithoutKey.checksum()
+ ". Expected " + key.getChecksum(),
key.getOffset());
代码示例来源: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;
}
}
代码示例来源: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;
}
内容来源于网络,如有侵权,请联系作者删除!