use of org.apache.pulsar.common.api.proto.PulsarApi.MessageIdData in project incubator-pulsar by apache.
the class RawMessageImpl method deserializeFrom.
public static RawMessage deserializeFrom(ByteBuf buffer) {
try {
int idSize = buffer.readInt();
int writerIndex = buffer.writerIndex();
buffer.writerIndex(buffer.readerIndex() + idSize);
ByteBufCodedInputStream stream = ByteBufCodedInputStream.get(buffer);
MessageIdData.Builder builder = MessageIdData.newBuilder();
MessageIdData id = builder.mergeFrom(stream, null).build();
buffer.writerIndex(writerIndex);
builder.recycle();
int payloadAndMetadataSize = buffer.readInt();
ByteBuf metadataAndPayload = buffer.slice(buffer.readerIndex(), payloadAndMetadataSize);
return new RawMessageImpl(id, metadataAndPayload);
} catch (IOException e) {
// This is in-memory deserialization, should not fail
log.error("IO exception deserializing ByteBuf (this shouldn't happen as operation is in-memory)", e);
throw new RuntimeException(e);
}
}
Aggregations