Skip to content

source: better handling of headers of type Data #544

Closed
@lburgazzoli

Description

@lburgazzoli

In the CamelSourceTask, if a Camel's header is of type date, it gets propagated as a string to Kafka with something like:

if (value instanceof Date) {
    record.headers().addString(
        keyCamelHeader, 
        new SimpleDateFormat("yyyy-MM-dd").format(value));
}

this approach has some issues:

  1. the consumer is not able to know the real type of the header as it is just a string
  2. we lose precision as we remove the time of the day

As Kafka support date and time with org.apache.kafka.connect.data.[Data|Time], we should probably avoid to use a string to represent dates however to fully translate a java.util.Date to the related Kafka types, we'd need to split it to multiple headers keys or using multiple headers for the same value.

I don't have enough knowledge at the moment about what could be the best solution but at least we should start by not losing the type.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions