You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by "dev-ankit (via GitHub)" <gi...@apache.org> on 2026/10/04 09:23:26 UTC
[PR] [feat][client] Expose message schema version [pulsar-client-node]
dev-ankit opened a new pull request, #509:
URL: https://github.com/apache/pulsar-client-node/pull/509
Master Issue: #362
This is the first of two parts. A follow-up PR will expose `Client.getSchemaInfo(topic, version)` so a consumer can fetch the writer schema for a given version.
### Motivation
A consumer of an Avro or JSON topic needs the writer schema version of each message to decode messages produced with an older, compatible schema. The Java client exposes this through `Message.getSchemaVersion()` and the Python client through `Message.schema_version()` / `int_schema_version()`. The bundled C++ client already provides `Message::hasSchemaVersion()` and `Message::getLongSchemaVersion()`, but the Node client does not expose them.
### Modifications
- `src/Message.h`, `src/Message.cc`: add `Message.getSchemaVersion()`. It returns the value of `getLongSchemaVersion()` as a number, or `null` when `hasSchemaVersion()` is false.
- `index.d.ts`: declare `getSchemaVersion(): number | null` on `Message`.
- `tstest.ts`: add a typing check for the new method.
- `tests/end_to_end.test.js`: add the `getSchemaVersion` test.
### Verifying this change
- [ ] Make sure that the change passes the CI checks.
This change added tests and can be verified as follows:
- Added the end-to-end test `getSchemaVersion`. It:
- subscribes and produces on a fresh topic with JSON schema V1, and asserts the received message reports version `0`;
- produces on the same topic with a compatible schema V2 (V1 plus a field with a default), and asserts the received message reports version `1`;
- produces and consumes on a fresh topic without a schema, and asserts the message reports `null`. With no schema, the broker registers no schema for the topic and the message metadata carries no schema version, so `hasSchemaVersion()` is false.
Locally, the test fails if `getSchemaVersion()` returns a constant.
### Documentation
- [x] `doc-required`
(The Node.js client docs and the client feature matrix on pulsar.apache.org will be updated in a follow-up.)
- [ ] `doc-not-needed`
- [ ] `doc`
- [ ] `doc-complete`
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [feat][client] Expose message schema version [pulsar-client-node]
Posted by "dev-ankit (via GitHub)" <gi...@apache.org>.
dev-ankit commented on PR #509:
URL: https://github.com/apache/pulsar-client-node/pull/509#issuecomment-6440099695
@gaoran10 renamed to `Message::GetLongSchemaVersion` in the binding
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [feat][client] Expose message schema version [pulsar-client-node]
Posted by "gaoran10 (via GitHub)" <gi...@apache.org>.
gaoran10 merged PR #509:
URL: https://github.com/apache/pulsar-client-node/pull/509
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [feat][client] Expose message schema version [pulsar-client-node]
Posted by "gaoran10 (via GitHub)" <gi...@apache.org>.
gaoran10 commented on PR #509:
URL: https://github.com/apache/pulsar-client-node/pull/509#issuecomment-6432452685
Could we follow the C++ naming convention? Such as `Message::GetLongSchemaVersion`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [feat][client] Expose message schema version [pulsar-client-node]
Posted by "graham-macdonald-simplisafe (via GitHub)" <gi...@apache.org>.
graham-macdonald-simplisafe commented on PR #509:
URL: https://github.com/apache/pulsar-client-node/pull/509#issuecomment-6426411024
+1 from a Node consumer of Avro-schema'd topics. This unblocks schema evolution for us.
Avro binary is positional, so a consumer can only read a message written with a newer or older (compatible) schema version if it knows the writer's schema and resolves it against its own, e.g. with avsc's `readerType.createResolver(writerType)`. Pulsar stamps every message with the writer's schema version, but the Node client doesn't expose it today, so Node consumers end up decoding with their own schema. That only works while producer and consumer are on the identical schema version; after a compatible change they either throw or mis-read values.
With `getSchemaVersion()` a consumer can look up the writer schema for that version (registry or cache) and resolve per message, which is what the Go, Java and .NET clients already allow. A `number` is what we'd use (the registry's `/schema/{version}` endpoint takes it), and `getLongSchemaVersion()` avoids the C API's `c_str()` truncation of the 8-byte version, which is a nice touch.
A `Client.getSchemaInfo(topic, version)` binding (the follow-up mentioned in #362) would complete the picture by letting consumers fetch the writer schema over the binary protocol rather than the admin REST API.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org