Skip to content

Serde: Enable header modifications by custom serializer #346

Open
@MDzajaS

Description

@MDzajaS

Issue submitter TODO list

  • I've searched for an already existing issues here
  • I'm running a supported version of the application which is listed here and the feature is not present there

Is your proposal related to a problem?

Some schema registries allow placing schema details in message headers instead of the payload. For example, Apicurio Registry serializer enables writing the artifact identifier to message headers.

However, when creating custom serializers that implement the io.kafbat.ui.serde.api.Serde interface with io.kafbat.ui.serde.api.Serde.Serializer, these interfaces don't provide direct access to message headers, which can be limiting.

Describe the feature you're interested in

Expend io.kafbat.ui.serde.api.Serde.Serializer to support message headers editing.

The least complicated solution would be to extend the serializer interface with additional method:

default byte[] serialize(String input, Headers headers) {
    return serialize(input);
}

Where Headers is org.apache.kafka.common.header.Headers, a mutable collection of headers.

If immutable headers are required (e.g., io.kafbat.ui.serde.api.RecordHeaders), then the interface might be extended with this method:

default SerializeResult serialize(String input, RecordHeaders headers) {
    return new SerializeResult(serialize(input), headers);
}

Where SerializeResult would be a new class that contains serialized message and headers.

By adding this method, io.kafbat.ui.serde.api.Serde.Serializer would move one step closer to Kafka's org.apache.kafka.common.serialization.Serializer interface.

Describe alternatives you've considered

There is no alternative for this feature. For instance, when using Apicurio Registry, if a serializer includes schema details directly in the message payload, it prepends a magic byte to the beginning of the message. If the deserializer doesn't expect this magic byte, it will not be able to read the message. So, to use Kafka-UI to produce messages with Apicurio Registry, it is necessary to modify message headers in the serializer.

Version you're running

2956664

Additional context

No response

Metadata

Metadata

Assignees

Labels

area/serdeSerialization & Deserialization (plugins)scope/backendRelated to backend changesstatus/triage/completedAutomatic triage completedtype/enhancementEn enhancement/improvement to an already existing feature

Projects

Status

In Review

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions