TsgcWSPClient_Kafka › Methods › FetchMessages
Reads records from a topic/partition starting at an offset, without a consumer group.
function FetchMessages(const aTopic: string; aPartition: Integer; aOffset: Int64; aMaxBytes: Integer = 0): TsgcKafkaMessages;
Reads records directly from a topic and partition starting at the given offset, without joining a consumer group and without affecting any committed offsets. This is useful for one-off reads or for replaying a known range of records. The records are returned as a TsgcKafkaMessages list; the caller owns the returned object and must free it.
var
oMessages: TsgcKafkaMessages;
i: Integer;
begin
oMessages := oKafka.FetchMessages('my-topic', 0, 0);
try
for i := 0 to oMessages.Count - 1 do
ShowMessage(oMessages.GetValueString(i));
finally
oMessages.Free;
end;
end;