Clients - kafka : Producer

Represent a Kafka producer endpoint.

Constructor

__init

(ProducerConfig config)

  • config ProducerConfig
  • Configurations related to initializing a Kafka Producer.

Remote Methods

close

Closes producer connection to the external Kafka broker.

commitConsumer

Commits consumer action which commits consumer consumed offsets to offset topic.

commitConsumerOffsets

CommitConsumerOffsets action which commits consumer offsets in given transaction.

flushRecords

Flush action which flush batch of records.

getTopicPartitions

GetTopicPartitions action which returns given topic partition information.

send

Simple Send action which produce records to Kafka server.

Fields

  • producerConfig ProducerConfig? ()
  • Used to store configurations related to a Kafka connection.

  • connectorId string system:uuid()
  • Unique ID for a particular connector.

close

()

returns ProducerError?

Closes producer connection to the external Kafka broker.

  • Return Type

    (ProducerError?)
  • kafka:ProducerError if closing the producer failed, nil otherwise.

commitConsumer

(Consumer consumer)

returns ProducerError?

Commits consumer action which commits consumer consumed offsets to offset topic.

Parameters

  • consumer Consumer
  • Consumer which needs offsets to be committed.

  • Return Type

    (ProducerError?)
  • kafka:ProducerError if committing the consumer failed, nil otherwise.

commitConsumerOffsets

(PartitionOffset offsets, string groupID)

returns ProducerError?

CommitConsumerOffsets action which commits consumer offsets in given transaction.

Parameters

  • offsets PartitionOffset
  • Consumer offsets to commit for given transaction.

  • groupID string
  • Consumer group id.

  • Return Type

    (ProducerError?)
  • kafka:ProducerError if committing consumer offsets failed, nil otherwise.

flushRecords

()

returns ProducerError?

Flush action which flush batch of records.

  • Return Type

    (ProducerError?)
  • kafka:ProducerError if records couldn't be flushed, nil otherwise.

getTopicPartitions

(string topic)

returns TopicPartition | ProducerError

GetTopicPartitions action which returns given topic partition information.

Parameters

  • topic string
  • Topic which the partition information is given.

  • Return Type

    (TopicPartition | ProducerError)
  • kafka:TopicPartition array for the given topic, returns kafka:ProducerError if operation fails.

send

(byte value, string topic, byte key, int partition, int timestamp)

returns ProducerError?

Simple Send action which produce records to Kafka server.

Parameters

  • value byte
  • Record contents.

  • topic string
  • Topic to which the record will be appended to.

  • key byte (default ())
  • Key that will be included in the record.

  • partition int (default ())
  • Partition to which the record should be sent.

  • timestamp int (default ())
  • Timestamp of the record, in milliseconds since epoch.

  • Return Type

    (ProducerError?)
  • Returns kafka:ProducerError if send action fails to send data, nil otherwise.