Giter Club home page Giter Club logo

Comments (7)

fabiojose avatar fabiojose commented on August 14, 2024

We don't have implemented this extension yet. PRs are welcome!

from sdk-java.

slinkydeveloper avatar slinkydeveloper commented on August 14, 2024

Since now the sdk provides only a value *Serializer and not a producer anymore, I'm not sure where this functionality should live... Maybe in a key serializer that gets an event and extracts the key?

BTW for reference this is how I implemented it in sdk-go: https://github.com/cloudevents/sdk-go/pull/437/files#diff-fc52ba8f8c260341995925b8297d6144R24 . Basically the message writer (in this sdk is mapped to the concept of visitors, so KafkaProducerMessageVisitorImpl and KafkaSerializerMessageVisitorImpl) tries to see if there is partitionKey in the message. If there is, it uses it as key of the record. I think this is feasible and trivial to implement for KafkaProducerMessageVisitorImpl (aka in case the user invokes manually the unmarshalling process), but for the CloudEventSerializer I'm not sure it makes sense, since that serializer works only with headers and body of the message.

from sdk-java.

bluemonk3y avatar bluemonk3y commented on August 14, 2024

An interceptor is required. The serializer won't have access to headers or the key and value - whereas the interceptors do. I raised a ticket for this previously.

https://kafka.apache.org/10/javadoc/org/apache/kafka/clients/producer/ProducerRecord.html

Regards,
Neil.

from sdk-java.

bluemonk3y avatar bluemonk3y commented on August 14, 2024

@slinkydeveloper - implementing something that does not support general producer and consumer use means the support for CloudEvents becomes limited. For example - Connectors, Stream Processors cannot interact natively with the Record. The correct approach is to use an interceptor and remove any code the tries to replace or reimplement Producers and Consumers. At that point an Interceptor is required in order to 1) determine the partition key 2) to write to the KafkaHeader.

from sdk-java.

slinkydeveloper avatar slinkydeveloper commented on August 14, 2024

@bluemonk3y that sounds interesting, are you willing to PR a poc (even not working) for that based on the actual code? I don't have enough expertise on Interceptors to understand if we really need them or not. I'll give a look next week to Interceptors...
I would love to keep the Serializer/Deserializer if we can because they're damn simple to use (and afaik they work with streams and connectors https://docs.confluent.io/current/streams/developer-guide/datatypes.html)

from sdk-java.

bluemonk3y avatar bluemonk3y commented on August 14, 2024

from sdk-java.

slinkydeveloper avatar slinkydeveloper commented on August 14, 2024

I think we can provide an interceptor that assigns the partitionKey and then serialization is done as usual by CloudEventSerializer. I'm working on it

from sdk-java.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.