TsgcWSPClient_KafkaMethods › ProduceMessages

ProduceMessages Method

Publishes a batch of records to a partition.

Syntax

function ProduceMessages(const aTopic: string; aPartition: Integer; const aMessages: TsgcKafkaMessages): TsgcKafkaProduceResponse;

Parameters

Remarks

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.

Example

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;

Back to Methods