MyGit

v0.11.4

confluentinc/confluent-kafka-go

版本发布时间: 2018-03-29 01:08:46

confluentinc/confluent-kafka-go最新发布版本:v2.3.0(2023-10-25 23:55:38)

Announcements

Message header support

Support for Kafka message headers has been added (requires broker version >= v0.11.0).

When producing messages, pass a []kafka.Header list:

        err = p.Produce(&kafka.Message{
                TopicPartition: kafka.TopicPartition{Topic: &topic, Partition: kafka.PartitionAny},
                Value:          []byte(value),
                Headers:        []kafka.Header{{"myTestHeader", []byte("header values are binary")}},
        }, deliveryChan)

Message headers are available to the consumer as Message.Headers:

	msg, err := c.ReadMessage(-1)
	if err != nil {
		fmt.Printf("%% Consumer error: %v\n", err)
		continue
	}
	fmt.Printf("%% Message on %s:\n%s\n", msg.TopicPartition, string(msg.Value))
	if msg.Headers != nil {
		fmt.Printf("%% Headers: %v\n", msg.Headers)
	}

Enhancements

Fixes

相关地址:原始地址 下载(tar) 下载(zip)

查看:2018-03-29发行的版本