TsgcWSPClient_Kafka › Methods › ProduceMessages
Publishes a batch of records to a partition.
function ProduceMessages(const aTopic: string; aPartition: Integer; const aMessages: TsgcKafkaMessages): TsgcKafkaProduceResponse;
Sends several records to a single partition in one produce request, which is more efficient than calling Produce once per record. The returned TsgcKafkaProduceResponse reports the result of the batch, including the base offset assigned by the broker. Build the TsgcKafkaMessages list, populate each record value and key, then pass it to this method.
var
oMessages: TsgcKafkaMessages;
oResponse: TsgcKafkaProduceResponse;
begin
oMessages := TsgcKafkaMessages.Create;
try
oMessages.Add('key-1', 'first');
oMessages.Add('key-2', 'second');
oResponse := oKafka.ProduceMessages('my-topic', 0, oMessages);
finally
oMessages.Free;
end;
end;