TsgcWSPClient_Kafka › Methods › Poll
Fetches available records, waiting up to a timeout.
function Poll(aTimeoutMs: Integer = 1000): TsgcKafkaMessages;
Fetches the records currently available for the subscribed topics, waiting up to aTimeoutMs milliseconds if none are ready. The records are returned as a TsgcKafkaMessages list and the OnKafkaMessage event is also raised once per record. The caller owns the returned object and must free it. Call Poll repeatedly in a loop to keep consuming.
var
oMessages: TsgcKafkaMessages;
i: Integer;
begin
oMessages := oKafka.Poll(1000);
try
for i := 0 to oMessages.Count - 1 do
ShowMessage(oMessages.GetValueString(i));
finally
oMessages.Free;
end;
end;