nic-6443 opened a new pull request, #13521:
URL: https://github.com/apache/apisix/pull/13521

   ### Description
   
   Messages produced by the kafka-logger plugin always have `CreateTime: -1`, 
so consumers see the message timestamp as `1970-01-01`.
   
   The root cause is that lua-resty-kafka defaults the Produce API version to 
1, which uses message format v0 — a format that doesn't carry a timestamp, so 
brokers store `-1`. Only `api_version = 2` (message format v1) carries the 
producer timestamp, but the plugin neither exposes `api_version` in its schema 
nor passes it to the producer config, so there is no way for users to enable it.
   
   This PR adds an `api_version` attribute (integer, enum `[0, 1, 2]`) to the 
kafka-logger schema and propagates it to the lua-resty-kafka producer config. 
The default stays `1` (same as lua-resty-kafka's default), so existing setups 
are unaffected; setting it to `2` makes brokers store message timestamps 
(requires Kafka >= 0.10). Docs (en/zh) are updated accordingly.
   
   The earlier closed PR #13040 proposed the same `api_version` part, which was 
right; its Kafka 4.x compatibility part was a separate concern and is not 
included here.
   
   The added regression test produces a log entry with `api_version = 2` and 
fetches it back via `resty.kafka.basic-consumer`, asserting the stored 
timestamp is greater than 0 (it is `-1` without this fix).
   
   #### Which issue(s) this PR fixes:
   
   Fixes #11811
   
   ### Checklist
   
   - [x] I have explained the need for this PR and the problem it solves
   - [x] I have explained the changes or the new features added to this PR
   - [x] I have added tests corresponding to this change
   - [x] I have updated the documentation to reflect this change
   - [x] I have verified that this change is backward compatible (If not, 
please discuss on the [APISIX mailing 
list](https://github.com/apache/apisix/tree/master#community) first)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to