Sarama: How to realize timestamp in producer?

Created on 21 Nov 2017  路  4Comments  路  Source: Shopify/sarama

I want to produce messages to kafka to use with mysql.

ksql show these:

has invalid (negative) timestamp. Possibly because a pre-0.10 producer client was used to write this record to Kafka without embedding a timestamp, or because the input topic was created before upgrading the Kafka cluster to 0.10+. Use a different TimestampExtractor to process this data.

Then I found.

https://docs.confluent.io/current/streams/developer-guide/config-streams.html#streams-developer-guide-timestamp-extractor

But how to realize in golang???

Most helpful comment

Sarama will add timestamps if it is producing to a broker of at least Kafka 0.10 as determined by config.Version. Just set that value correctly and new messages should be produced with timestamps.

All 4 comments

Sarama will add timestamps if it is producing to a broker of at least Kafka 0.10 as determined by config.Version. Just set that value correctly and new messages should be produced with timestamps.

@eapache where to set config.Version Thanks.

When you call NewAsyncProducer or NewSyncProducer the last parameter is the config object. Set it on that.

Thanks.

Was this page helpful?
0 / 5 - 0 ratings