Comments (7)
We don't have implemented this extension yet. PRs are welcome!
from sdk-java.
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.
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.
@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.
@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.
from sdk-java.
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)
- BaseCloudEvent.getExtensionNames() breaks cloud event encapsulation HOT 2
- Add benchmarks to CloudEvents SQL HOT 1
- Does CloudEventDeserializer deserialize custom extensions (kafka headers)? HOT 3
- CVE-2022-42004 - Update jackson version HOT 3
- Spring Webflux: example not working HOT 2
- Custom validation for context attributes in wrapper library HOT 1
- can't setup `cloudevents.serializer.event_format` in quarkus HOT 3
- How to transport List<CloudEvent> between Springboot services by openfeign?
- Running into exception while using cloudevent values in kafka streams HOT 1
- Enhancement: generalise the validation in wrapper library HOT 4
- Change type of source attribute from URI to String HOT 2
- Add support for spring-amqp HOT 1
- Contribution question for wrapper for RabbitmQ and Redis HOT 8
- Port tck tests once the CESQL spec stabilizes more HOT 1
- Error assembling JAR: Invalid automatic module name: '' HOT 1
- Cannot invoke "java.lang.ClassLoader.getParent()" because "this.currentLoader" is null
- CloudEventHttpMessageConverter can't convert List<CloudEvent>
- JsonFormat doesn't accept valid datacontentypes
- v4.0.1 git tag included commit for 4.0.2-SNAPSHOT
- cloud events sdk for java 17
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sdk-java.