You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by rg...@apache.org on 2025/05/21 16:17:00 UTC
(pulsar) branch add-pip-413 created (now 9087b06f4c3)
This is an automated email from the ASF dual-hosted git repository.
rgao pushed a change to branch add-pip-413
in repository https://gitbox.apache.org/repos/asf/pulsar.git
at 9087b06f4c3 change pip number
This branch includes the following new commits:
new 87a2fed62d6 add pip 413
new 32981d6743d fix
new c51f6c95df5 fix
new 94a3f08f609 fix
new 9087b06f4c3 change pip number
The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(pulsar) 03/05: fix
Posted by rg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rgao pushed a commit to branch add-pip-413
in repository https://gitbox.apache.org/repos/asf/pulsar.git
commit c51f6c95df59e108640a825d864ff735cdefe540
Author: gaoran_10@126.com <ga...@126.com>
AuthorDate: Wed May 21 19:03:33 2025 +0800
fix
---
pip/pip-413.md | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/pip/pip-413.md b/pip/pip-413.md
index e1efb0c9fb9..80a2a42067a 100644
--- a/pip/pip-413.md
+++ b/pip/pip-413.md
@@ -217,6 +217,11 @@ public interface Schema {
}
```
+# Pulsar Function
+
+For supporting using external schema registry service in Pulsar Function,
+the function configurations should support setting the `SchemaInfoProviderFactory` and schema registry auth configurations.
+
# Security Considerations
Users can provide security configuration while generating the `SchemaInfoProviderFactory` instance,
the factory can transfer the security configuration to the `SchemaInfoProvider` instance.
(pulsar) 04/05: fix
Posted by rg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rgao pushed a commit to branch add-pip-413
in repository https://gitbox.apache.org/repos/asf/pulsar.git
commit 94a3f08f6098886935a2e4c6cc9a382a35ba6077
Author: gaoran_10@126.com <ga...@126.com>
AuthorDate: Thu May 22 00:11:52 2025 +0800
fix
---
pip/pip-413.md | 23 +++++++++++------------
1 file changed, 11 insertions(+), 12 deletions(-)
diff --git a/pip/pip-413.md b/pip/pip-413.md
index 80a2a42067a..89cc4234814 100644
--- a/pip/pip-413.md
+++ b/pip/pip-413.md
@@ -1,26 +1,26 @@
-# PIP-413: Decouple schema management from messaging protocols for Pulsar clients
+# PIP-413: Provide ability for Pulsar clients to integrate with third-party schema registry service
# Background knowledge
Schema is an important feature for messaging systems. Pulsar integrates schema manager into the Pulsar broker.
-The current implementation in Pulsar clients couples schema management with some protocols. This increases the Pulsar protocol complexity;
-and users can’t leverage other schema registry services in Pulsar client, such as Kafka Schema Registry.
+The current implementation in Pulsar clients couples schema management with some protocols (creating producer, adding consumer subscription).
+This increases the Pulsar protocol complexity and users can’t leverage third-party schema registry services in Pulsar client.
# Motivation
-The Pulsar client is better has the ability to access external schema registry service to manage the schema (register schema,
-get schema, validate schema, etc.). The schema registry service can be an independent service, if using external schema registry service,
+The Pulsar client is better has the ability to access third-party schema registry service to manage the schema (register schema,
+get schema, validate schema, etc.). The schema registry service can be an independent service, if using third-party schema registry service,
the Pulsar broker doesn't need to care about the schema of the messages.
# Goals
## In Scope
-- Provide an ability to leverage external schema registry service for Pulsar client.
+- Provide an ability to leverage third-party schema registry service for Pulsar client.
## Out Scope
-This PIP will not include the implementation for accessing external schema system.
+This PIP will not include the implementation for accessing third-party schema system.
# High Level Design
@@ -56,7 +56,6 @@ public void workWithExternalSchemaRegistry() throws Exception {
.build();
String topic = "t1";
-
Schema<User> schema = KafkaSchemas.JSON(User.class);
Producer<User> producer = client.newProducer(schema)
@@ -109,7 +108,7 @@ public class ProducerImpl<T> extends ProducerBase<T> implements TimerTask, Conne
// ...
if (schema.getSchemaInfoProvider().isExternal()) {
- // don't register schema if the schema is external, the register method can be integrated in the messaging encode method.
+ // don't register schema if external schema registry service, the register method can be integrated in the messaging encode method.
return;
}
// getOrCreateSchemaAsync
@@ -219,15 +218,15 @@ public interface Schema {
# Pulsar Function
-For supporting using external schema registry service in Pulsar Function,
-the function configurations should support setting the `SchemaInfoProviderFactory` and schema registry auth configurations.
+For supporting using third-party schema registry service in Pulsar Function,
+the function configurations should support setting the `SchemaInfoProviderFactory` and schema registry auth configurations while initializing the Pulsar client.
# Security Considerations
Users can provide security configuration while generating the `SchemaInfoProviderFactory` instance,
the factory can transfer the security configuration to the `SchemaInfoProvider` instance.
# Pulsar-GEO replication
-If users can use external schema registry service, it provides a new way to manage scheme for geo-replicated topics.
+If users can use third-party schema registry service, it provides a new way to manage scheme for geo-replicated topics.
# Backward & Forward Compatibility
(pulsar) 02/05: fix
Posted by rg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rgao pushed a commit to branch add-pip-413
in repository https://gitbox.apache.org/repos/asf/pulsar.git
commit 32981d6743d76bb1c17e96e08de7d1ac80f19876
Author: gaoran_10@126.com <ga...@126.com>
AuthorDate: Mon May 19 21:55:41 2025 +0800
fix
---
pip/pip-413.md | 127 +++++++++++++++++++++++++++++++++++++++++++++++++++------
1 file changed, 115 insertions(+), 12 deletions(-)
diff --git a/pip/pip-413.md b/pip/pip-413.md
index c889548d745..e1efb0c9fb9 100644
--- a/pip/pip-413.md
+++ b/pip/pip-413.md
@@ -1,27 +1,26 @@
-# PIP-413: Support use external schema registry service for Pulsar client
+# PIP-413: Decouple schema management from messaging protocols for Pulsar clients
# Background knowledge
Schema is an important feature for messaging systems. Pulsar integrates schema manager into the Pulsar broker.
-This implementation has some weaknesses. Managing the schema increases the Pulsar broker and Pulsar protocol complexity;
-users can’t leverage other schema registry services in Pulsar client, such as Kafka Schema Registry.
+The current implementation in Pulsar clients couples schema management with some protocols. This increases the Pulsar protocol complexity;
+and users can’t leverage other schema registry services in Pulsar client, such as Kafka Schema Registry.
# Motivation
-The Pulsar client should have the ability to access external schema registry service to manage the schema (register schema,
+The Pulsar client is better has the ability to access external schema registry service to manage the schema (register schema,
get schema, validate schema, etc.). The schema registry service can be an independent service, if using external schema registry service,
-the Pulsar broker don't need to care about the schema of the messages.
+the Pulsar broker doesn't need to care about the schema of the messages.
# Goals
## In Scope
-- Support using external schema registry service for Pulsar client.
+- Provide an ability to leverage external schema registry service for Pulsar client.
## Out Scope
-This PIP will not include the implementation for accessing external schema system,
-and not include the Pulsar external schema registry service design.
+This PIP will not include the implementation for accessing external schema system.
# High Level Design
@@ -34,8 +33,9 @@ This PIP is just for providing some abilities.
## Design & Implementation Details
-This PIP's target is making Pulsar client has the ability to leverage external schema registry service to manage schema.
-The external schema registry is responsible for managing the schema, the broker don't care about the messaging schema.
+This PIP's target is decoupling schema management from Pulsar messaging protocols,
+and making Pulsar client have the ability to leverage external schema registry service to manage schema.
+The external schema registry is responsible for managing the schema, the broker doesn't care about the messaging schema.
The Pulsar client should ignore the schema information when creating producer and adding consumer subscription.
Users can implement the `SchemaInfoProvider` interface and `Schema` interface to access external schema registry service.
@@ -44,10 +44,108 @@ The encoded messaging depends on the external schema system, Pulsar broker just
Unlike Pulsar using schema version to identify the schema, some external schema system use the schema ID to identify the schema,
if using external schema system the Pulsar message metadata will not maintain schema ID, the customized decoding method can try to retrieve the schema ID from the encoded data.
+Example usage
+```java
+public void workWithExternalSchemaRegistry() throws Exception {
+ Map<String, String> srConfig = new HashedMap<>();
+ srConfig.put("schema.registry.url", "http://localhost:8001");
+
+ PulsarClient client = PulsarClient.builder()
+ .serviceUrl("pulsar://localhost:6650")
+ .schemaInfoProviderFactory(new KafkaSchemaInfoProviderFactory(srConfig))
+ .build();
+
+ String topic = "t1";
+
+ Schema<User> schema = KafkaSchemas.JSON(User.class);
+
+ Producer<User> producer = client.newProducer(schema)
+ .topic(topic)
+ .create();
+
+ Consumer<User> consumer = client.newConsumer(schema)
+ .topic(topic)
+ .subscriptionName("sub")
+ .subscriptionInitialPosition(SubscriptionInitialPosition.Earliest)
+ .subscribe();
+
+ for (int i = 0; i < 10; i++) {
+ producer.send(new User("name-" + i, 10 + i));
+ }
+
+ for (int i = 0; i < 10; i++) {
+ Message<User> message = consumer.receive();
+ consumer.acknowledge(message);
+ }
+
+ client.close();
+}
+```
+
+Messaging protocols changes
+
+Ignore schema info while creating Producer, ignore register schema before sending messages, the schema management
+```java
+public class ProducerImpl<T> extends ProducerBase<T> implements TimerTask, ConnectionHandler.Connection {
+
+ @Override
+ public CompletableFuture<Void> connectionOpened(final ClientCnx cnx) {
+ // ...
+
+ if (schema != null && schema.getSchemaInfoProvider() != null && schema.getSchemaInfoProvider().isExternal()) {
+ try {
+ // set schemaInfo to null if the schema info provider is external
+ schemaInfo = null;
+ } catch (Exception e) {
+ log.error("Failed to register schema.", e);
+ throw new RuntimeException(e);
+ }
+ }
+
+ // send create producer request
+ }
+
+ private void tryRegisterSchema(ClientCnx cnx, MessageImpl msg, SendCallback callback, long expectedCnxEpoch) {
+ // ...
+
+ if (schema.getSchemaInfoProvider().isExternal()) {
+ // don't register schema if the schema is external, the register method can be integrated in the messaging encode method.
+ return;
+ }
+ // getOrCreateSchemaAsync
+ }
+
+}
+```
+
+Ignore schema info while adding consumer subscription.
+```java
+public class ConsumerImpl<T> extends ConsumerBase<T> implements ConnectionHandler.Connection {
+
+ @Override
+ public CompletableFuture<Void> connectionOpened(final ClientCnx cnx) {
+ // ...
+
+ // only external schema info provider need to register schema
+ if (schema.getSchemaInfoProvider() != null && schema.getSchemaInfoProvider().isExternal()) {
+ try {
+ // don't set schema info for schema registry schema
+ si = null;
+ } catch (Exception e) {
+ log.error("Failed to register schema.", e);
+ throw new RuntimeException(e);
+ }
+ }
+
+ }
+
+}
+```
+
## Public-facing Changes
Add new methods for `SchemaInfoProvider` interface.
-The `SchemaInfoProvider` provide necessary params for connecting to the external schema registry service with the method `getConfigs`.
+The `SchemaInfoProvider` provides necessary params for connecting to the external schema registry service with the method `getConfigs`.
If the schema info provider is external, the new producer command, consumer subscribe command will treat the schema as bytes schema, the broker will ignore schema validation.
```java
public interface SchemaInfoProvider {
@@ -119,7 +217,12 @@ public interface Schema {
}
```
-### CLI
+# Security Considerations
+Users can provide security configuration while generating the `SchemaInfoProviderFactory` instance,
+the factory can transfer the security configuration to the `SchemaInfoProvider` instance.
+
+# Pulsar-GEO replication
+If users can use external schema registry service, it provides a new way to manage scheme for geo-replicated topics.
# Backward & Forward Compatibility
(pulsar) 05/05: change pip number
Posted by rg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rgao pushed a commit to branch add-pip-413
in repository https://gitbox.apache.org/repos/asf/pulsar.git
commit 9087b06f4c3f7cd62dee63fac6206afbaca83de6
Author: gaoran_10@126.com <ga...@126.com>
AuthorDate: Thu May 22 00:12:50 2025 +0800
change pip number
---
pip/{pip-413.md => pip-417.md} | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pip/pip-413.md b/pip/pip-417.md
similarity index 99%
rename from pip/pip-413.md
rename to pip/pip-417.md
index 89cc4234814..d0c885a342f 100644
--- a/pip/pip-413.md
+++ b/pip/pip-417.md
@@ -1,4 +1,4 @@
-# PIP-413: Provide ability for Pulsar clients to integrate with third-party schema registry service
+# PIP-417: Provide ability for Pulsar clients to integrate with third-party schema registry service
# Background knowledge
(pulsar) 01/05: add pip 413
Posted by rg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rgao pushed a commit to branch add-pip-413
in repository https://gitbox.apache.org/repos/asf/pulsar.git
commit 87a2fed62d6253e4c8baca2e1fc10360701c84ca
Author: gaoran_10@126.com <ga...@126.com>
AuthorDate: Mon May 19 10:33:57 2025 +0800
add pip 413
---
pip/pip-413.md | 146 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 146 insertions(+)
diff --git a/pip/pip-413.md b/pip/pip-413.md
new file mode 100644
index 00000000000..c889548d745
--- /dev/null
+++ b/pip/pip-413.md
@@ -0,0 +1,146 @@
+# PIP-413: Support use external schema registry service for Pulsar client
+
+# Background knowledge
+
+Schema is an important feature for messaging systems. Pulsar integrates schema manager into the Pulsar broker.
+This implementation has some weaknesses. Managing the schema increases the Pulsar broker and Pulsar protocol complexity;
+users can’t leverage other schema registry services in Pulsar client, such as Kafka Schema Registry.
+
+# Motivation
+
+The Pulsar client should have the ability to access external schema registry service to manage the schema (register schema,
+get schema, validate schema, etc.). The schema registry service can be an independent service, if using external schema registry service,
+the Pulsar broker don't need to care about the schema of the messages.
+
+# Goals
+
+## In Scope
+
+- Support using external schema registry service for Pulsar client.
+
+## Out Scope
+
+This PIP will not include the implementation for accessing external schema system,
+and not include the Pulsar external schema registry service design.
+
+# High Level Design
+
+This PIP is just for providing some abilities.
+
+- Decouple schema management from creating producer or add consumer subscription commands.
+- Provide a way to build external schema management system clients and integrate with Pulsar clients.
+
+# Detailed Design
+
+## Design & Implementation Details
+
+This PIP's target is making Pulsar client has the ability to leverage external schema registry service to manage schema.
+The external schema registry is responsible for managing the schema, the broker don't care about the messaging schema.
+The Pulsar client should ignore the schema information when creating producer and adding consumer subscription.
+
+Users can implement the `SchemaInfoProvider` interface and `Schema` interface to access external schema registry service.
+The `Schema` interface has mainly two methods `encode` and `decode`, the customized schemas can register schema or get schema with these methods.
+The encoded messaging depends on the external schema system, Pulsar broker just treats the message as bytes data, and it won't change the message version of message metadata.
+Unlike Pulsar using schema version to identify the schema, some external schema system use the schema ID to identify the schema,
+if using external schema system the Pulsar message metadata will not maintain schema ID, the customized decoding method can try to retrieve the schema ID from the encoded data.
+
+## Public-facing Changes
+
+Add new methods for `SchemaInfoProvider` interface.
+The `SchemaInfoProvider` provide necessary params for connecting to the external schema registry service with the method `getConfigs`.
+If the schema info provider is external, the new producer command, consumer subscribe command will treat the schema as bytes schema, the broker will ignore schema validation.
+```java
+public interface SchemaInfoProvider {
+
+ /**
+ * Returns the configs of the schema registry service, such as URL, authentication params.
+ */
+ default Map<String, String> getConfigs() {
+ return Collections.emptyMap();
+ }
+
+ /**
+ * It's used to determine whether the SchemaInfoProvider is external or not.
+ */
+ default boolean isExternal() {
+ return false;
+ }
+
+}
+```
+
+Add a new interface `SchemaInfoProviderFactory`, it's used to initialize `SchemaInfoProvider`, each topic has its own `SchemaInfoProvider`.
+```java
+public interface SchemaInfoProviderFactory {
+
+ SchemaInfoProvider of(String topic);
+
+}
+```
+
+The client build supports setting the `SchemaInfoProviderFactory`.
+```java
+public interface ClientBuilder extends Serializable, Cloneable {
+
+ ClientBuilder schemaInfoProviderFactory(SchemaInfoProviderFactory schemaInfoProviderFactory);
+
+}
+```
+
+The `ClientConfigurationData` supports transfer `SchemaInfoProviderFactory`.
+```java
+public class ClientConfigurationData implements Serializable, Cloneable {
+
+ @JsonIgnore
+ private transient SchemaInfoProviderFactory schemaInfoProviderFactory;
+
+}
+```
+
+The customized schema can get the `SchemaInfoProvider` and retrieve the configs from it.
+```java
+public interface Schema {
+
+ /**
+ * When setting schema info provider for schema, the schema can retrieve the configs.
+ */
+ default void setSchemaInfoProvider(SchemaInfoProvider schemaInfoProvider) {
+ }
+
+ /**
+ * Returns the schema info provider.
+ *
+ * @return a {@code SchemaInfoProvider} representing the schema info provider
+ */
+ default SchemaInfoProvider getSchemaInfoProvider() {
+ return null;
+ }
+
+}
+```
+
+### CLI
+
+# Backward & Forward Compatibility
+
+## Revert
+
+No changes are needed to revert to the previous version.
+
+## Upgrade
+
+No other changes are needed to upgrade to the new version.
+
+# Alternatives
+
+None
+
+# General Notes
+
+# Links
+
+<!--
+Updated afterwards
+-->
+* Mailing List discussion thread: https://lists.apache.org/thread/olx4xm8cdy43omp5c0jm44sj1gp0grcr
+* Mailing List voting thread: https://lists.apache.org/thread/vhq6ox4nh2rx59yoxowftqzv8f9lnm4q