-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a Message.getSchema() in the client API #10438
Comments
@congbobo184 here https://github.com/apache/pulsar/pull/9970/files#diff-955419b4b0ad976e96f9f7595989e79c391109aeaa304bd286a80fc6eb9360c7R324 you are adding MessageImpl#getSchema() with CompletableFuture but why can't we use directly the schema instance that is cached inside the Message ? |
Related work: pulsar/pulsar-broker/src/test/java/org/apache/pulsar/client/api/SimpleSchemaTest.java Line 530 in 7c0a798
|
The problem with AUTO_CONSUME and especially while dealing with multi-version schemas, is that Message.getSchema() should return the exact schema applied to the message, that is the schema identified by "topic" + "schemaVersion". |
As discussed at the community meeting I am going to send a PIP |
#10476 is merged, so close this issue. |
When the schema is not known at compile time, a
Consumer<GenericObject>
should be able to get the message schema.Currently, a
Consumer<GenericRecord>
can get the AVRO message and retreive its schema, but if the message is a KeyValue for example, there is no way to get the actual Schema.The idea is to introduce a
CompletableFuture<Schema<?>> getSchema()
in the Message API, returning null by default.The implementation classes (MessageImpl, TopicMessageImpl) could then fetch the Schema if available, and eventually keep it cached as a class member.
The text was updated successfully, but these errors were encountered: