如Pulsar Schema Registry Docs中的示例所示
Producer<User> producer = client.newProducer(JSONSchema.of(User.class))
.topic(topic)
.create();
User user = new User(“Tom”, 28);
producer.send(User);
您可以使用 Java 客户端为生产者和消费者注册模式。还提到其他语言的客户端不支持模式注册表。
现在是否可以从 Python API 生产者发送关于 Pulsar 主题的消息,该消息将由具有注册模式的消费者使用?例如
processor = PulsarClient.builder()
.serviceUrl("pulsar://pulsarhost:6650")
.build()
.newConsumer(JSONSchema.of(User.class))
.topic("sometopic")
.subscriptionName("somesubscription")
.subscribe();
Python:导入脉冲星
client = pulsar.Client('pulsar://pulsarhost:6650')
producer = client.create_producer('sometopic')
client.close()