Skip to content

Export Pulsar topics with Apicurio Registry schemas

Schemas live in Apicurio instead of Pulsar? They are exported too.

Terminal recording of kurkik pulsar export

The recording shows kurkik pulsar export on the demo sandbox; its data differs from this example.

Terminal window
kurkik pulsar export standalone
asyncapi.yaml
asyncapi: 3.0.0
info:
title: standalone Apache Pulsar API
version: 1.0.0-SNAPSHOT
description: Generated by reading Apache Pulsar of standalone (http://pulsar-standalone:8080).
servers:
standalone:
host: pulsar-standalone:6650
protocol: pulsar
protocolVersion: "4.0"
description: Apache Pulsar cluster standalone.
bindings:
pulsar:
bindingVersion: 0.1.0
tenant: shop
x-kurkik:
pulsar:
server:
cluster: standalone
brokers:
- localhost:8080
schemaRegistryUrl: http://apicurio:8080
schemaRegistryVendor: apicurio
namespacePolicies:
public/default:
schema-autoupdate: "on"
shop/orders:
schema-autoupdate: "on"
security:
- security: NONE
tls: false
functions: []
sources: []
sinks: []
brokerConfiguration:
advertisedAddress: localhost
backlogQuotaDefaultLimitGB: "10.0"
bookkeeperClientMinNumRacksPerWriteQuorum: "1"
bookkeeperClientReorderReadSequenceEnabled: "false"
bookkeeperNumberOfChannelsPerBookie: "1"
clusterName: standalone
enablePackagesManagement: "true"
forceDeleteNamespaceAllowed: "true"
functionsWorkerEnablePackageManagement: "true"
isRunningStandalone: "true"
loadBalancerEnabled: "false"
loadManagerClassName: org.apache.pulsar.broker.loadbalance.NoopLoadManager
managedLedgerCacheEvictionFrequency: "100.0"
managedLedgerDefaultAckQuorum: "1"
managedLedgerDefaultEnsembleSize: "1"
managedLedgerDefaultMarkDeleteRateLimit: "0.1"
managedLedgerDefaultWriteQuorum: "1"
metadataStoreUrl: rocksdb:///pulsar/data/metadata
packagesManagementStorageProvider: org.apache.pulsar.packages.management.storage.filesystem.FileSystemPackagesStorageProvider
statusFilePath: /usr/local/apache/htdocs
topicPublisherThrottlingTickTimeMillis: "2"
webSocketServiceEnabled: "true"
clientConfiguration:
serviceUrl: pulsar://pulsar-standalone:6650
webServiceUrl: http://pulsar-standalone:8080
producerConfiguration: {}
consumerConfiguration: {}
channels:
persistent-shop-orders-created:
address: persistent://shop/orders/created
messages:
persistent-shop-orders-created:
payload:
schemaFormat: application/vnd.apache.avro;version=1.9.0
schema:
type: record
name: Order
namespace: shop
fields:
- name: id
type: string
- name: total
type: double
name: persistent-shop-orders-created
title: persistent://shop/orders/created
summary: "Schema read from the Apicurio Registry: artifact persistent://shop/orders/created-value,\
\ version 1. Pulsar's own registry holds none for the topic: each payload\
\ carries the schema's ID."
x-kurkik:
pulsar:
message:
schemaIdLocation: payload
schemaIdPayloadEncoding: apicurio-new
schemaLookupStrategy: TopicIdStrategy
schemaVersion: 1
schemaCompatibility: NONE
key:
type: string
bindings:
pulsar:
bindingVersion: 0.1.0
namespace: orders
persistence: persistent
x-kurkik:
pulsar:
channel:
topic: persistent://shop/orders/created
tenant: shop
namespace: orders
persistence: persistent
partitions: 0
geo-replication:
- standalone
topicConfiguration:
partitions: 0
persistence: persistent
replication-clusters:
- standalone
schema-autoupdate: "on"
persistent-shop-orders-paid:
address: persistent://shop/orders/paid
bindings:
pulsar:
bindingVersion: 0.1.0
namespace: orders
persistence: persistent
x-kurkik:
pulsar:
channel:
topic: persistent://shop/orders/paid
tenant: shop
namespace: orders
persistence: persistent
partitions: 2
geo-replication:
- standalone
topicConfiguration:
partitions: 2
persistence: persistent
replication-clusters:
- standalone
schema-autoupdate: "on"
operations:
receive_persistent-shop-orders-created:
action: receive
channel:
$ref: "#/channels/persistent-shop-orders-created"
x-kurkik:
pulsar:
operation:
consumerConfiguration: {}
receive_persistent-shop-orders-paid:
action: receive
channel:
$ref: "#/channels/persistent-shop-orders-paid"
x-kurkik:
pulsar:
operation:
consumerConfiguration: {}
send_persistent-shop-orders-created:
action: send
channel:
$ref: "#/channels/persistent-shop-orders-created"
x-kurkik:
pulsar:
operation:
producerConfiguration: {}
send_persistent-shop-orders-paid:
action: send
channel:
$ref: "#/channels/persistent-shop-orders-paid"
x-kurkik:
pulsar:
operation:
producerConfiguration: {}

Download asyncapi.yaml

  • Pulsar holds no schema for created. The serde declares a BYTES schema named AvroPulsarSerdeSchema, and Pulsar’s client sends no BYTES schema, so nothing reaches the broker: pulsar-admin schemas get answers Schema not found. The payload carries the schema’s ID - a magic byte and a 4-byte ID, 5 bytes before the record.
  • So the message on created is the registry’s: artifact persistent://shop/orders/created-value, version 1, its compatibility, schemaIdLocation: payload, schemaIdPayloadEncoding: apicurio-new, schemaLookupStrategy: TopicIdStrategy, and no schemaType - Pulsar has none to give. The summary says so.
  • schemaRegistryVendor: apicurio, and the registry’s URL as schemaRegistryUrl.
  • paid has a schema neither in Pulsar nor in the registry: no message, and no limitation - nothing is missing.
  • Without --apicurio-url the same cluster exports as single-empty does: nothing on the topic says it is serialised through Apicurio. The scenario checks that too.
How to build this setup yourself

Clusters

Seed

Terminal window
pulsar-admin tenants create shop --allowed-clusters standalone --admin-roles shop-admin
pulsar-admin namespaces create shop/orders --clusters standalone
pulsar-admin topics create persistent://shop/orders/created
pulsar-admin topics create-partitioned-topic persistent://shop/orders/paid --partitions 2
val serde = AvroPulsarSerde<GenericRecord>("persistent://shop/orders/created")
serde.configure(SerdeConfig(mapOf("apicurio.registry.url" to "http://apicurio:8080/apis/registry/v3", "apicurio.registry.auto-register" to "true")), false)
client.newProducer(AvroPulsarSerdeSchema(serde)).topic("persistent://shop/orders/created").producerName("checkout-1").create()
.send(order) // {"id": "o-1", "total": 12.5}, an Order: {"type":"record","name":"Order","namespace":"shop","fields":[...]}

Export

Terminal window
kurkik conn add pulsar standalone --admin-url http://pulsar-standalone:8080 --service-url pulsar://pulsar-standalone:6650 --apicurio-url http://apicurio:8080
kurkik pulsar export standalone

All flags: kurkik pulsar export · more Apache Pulsar export examples