Kafka Connect TimestampConverter and JVM Default Time Zone: Regional String Interoperability Gap
0 reputation · 04 Oct 2023, 00:56 UTC
0 reputation · 04 Oct 2023, 00:56 UTC
In recent Kafka Connect releases, the TimestampConverter SMT converts fields between Unix epoch, string, date, and timestamp types. For string targets, it applies a format pattern but does not expose a dedicated time zone setting. Instead, formatting and parsing rely on the worker JVM's default time zone and locale. This creates an interoperability gap when identical connector configurations run on workers in different regional zones: the same epoch millis input can produce different local string representations, and downstream consumers may interpret ambiguous patterns without offset information.
Kafka record timestamps themselves are stored as epoch milliseconds in UTC, leaving regional interpretation to application-level serializers. The unresolved design decision is whether TimestampConverter should offer an explicit time zone configuration or continue delegating to JVM defaults, and how multi-region deployments should coordinate zone behavior without changing global worker settings.
Should TimestampConverter expose a per-transform time zone property, or is JVM default delegation the intended contract? How can teams guarantee consistent regional string output across Connect workers without altering the shared JVM locale? What verification approach reliably detects zone drift in existing pipelines before it reaches downstream consumers?
33275 reputation · 04 Oct 2023, 02:17 UTC
The current TimestampConverter SMT does not expose a per‑transform time‑zone setting; it uses the worker JVM’s ZoneId.systemDefault() and Locale.getDefault(). Therefore, to guarantee identical string output across a multi‑region Connect deployment you must ensure every worker runs with the same JVM default zone and locale (or isolate workers per region). There is no built‑in per‑transform override in Kafka Connect 3.5 and earlier.
-Duser.timezone=UTC (or your chosen zone) and -Duser.language=en arguments for every Connect process. In a Docker or Kubernetes environment this can be done via the image’s JAVA_OPTS or pod spec.
docker run -e JAVA_OPTS="-Duser.timezone=UTC -Duser.language=en" confluentinc/cp-kafka-connect:latest
1609459200000 (2021‑01‑01T00:00:00Z).
TimestampConverter with a known pattern. Example pattern: yyyy-MM-dd HH:mm:ss.
ZoneId.
Instant to the original epoch. Log or alert if the difference exceeds one second.
If you cannot enforce identical JVM defaults across workers (e.g., shared hosts with differing locales), you can implement a lightweight wrapper SMT that accepts a timezone property and internally configures a DateTimeFormatter with that zone. This is a backward‑compatible extension that does not alter the original TimestampConverter contract.
Do you have the ability to set JVM arguments (e.g., -Duser.timezone) on every Connect worker in your environment? If not, the recommendation to use a custom SMT may be the only practical path to consistent string output.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.