Skip to content

Sync Pulsar schemas that differ

What is refused, and what replacing does.

Terminal recording of kurkik pulsar sync

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

What you get if you do not ask for the risky part:

$ kurkik pulsar sync a.yaml b --schemas --dry-run
Sync a.yaml into b - Apache Pulsar, cluster b (http://pulsar-b:8080)
owns: namespaces shop/orders - the ones its channels live in; permissions, as x-kurkik.pulsar.server.acl declares them
plan: <digest>
Run one sync per cluster at a time: two at once each plan against a state the other is changing.
Nothing to change.
left alone (5)
schema differs persistent://shop/orders/created schemaType --overwrite --replace-schemas
The schema of persistent://shop/orders/created is AVRO in the document and JSON on the cluster, with the same structure. Its type can only be brought into line by deleting the topic's schema and uploading the document's versions: --overwrite --replace-schemas does that. sync converts no schema from one type to another. JSON to AVRO is not a conversion: messages already on the topic stay encoded as JSON, and a client still on the JSON schema cannot produce or read alongside one on AVRO.
schema differs persistent://shop/orders/paid history --overwrite --replace-schemas
schema differs persistent://shop/orders/raw schemaType --overwrite --replace-schemas
The schema of persistent://shop/orders/raw is JSON in the document and AVRO on the cluster, with the same structure. Its type can only be brought into line by deleting the topic's schema and uploading the document's versions: --overwrite --replace-schemas does that. sync converts no schema from one type to another. AVRO to JSON is not a conversion: messages already on the topic stay encoded as AVRO, and a client still on the AVRO schema cannot produce or read alongside one on JSON.
schema differs persistent://shop/orders/shipped schemaType --overwrite --replace-schemas
The schema of persistent://shop/orders/shipped is PROTOBUF in the document and AVRO on the cluster, and their structures differ. Its type can only be brought into line by deleting the topic's schema and uploading the document's versions: --overwrite --replace-schemas does that. sync converts no schema from one type to another.
and 1 difference sync does not act on - servers, messages, undeclared settings; kurkik pulsar diff shows them
0 changes
exit 0

Nothing changes yet. --dry-run only shows what would happen.

$ kurkik pulsar sync a.yaml b --schemas --overwrite --replace-schemas --dry-run
Sync a.yaml into b - Apache Pulsar, cluster b (http://pulsar-b:8080)
owns: namespaces shop/orders - the ones its channels live in; permissions, as x-kurkik.pulsar.server.acl declares them
plan: <digest>
Run one sync per cluster at a time: two at once each plan against a state the other is changing.
changes (4)
± replace persistent://shop/orders/created schemaType JSON -> AVRO [soft-deletes the subject's versions]
The schema of persistent://shop/orders/created is AVRO in the document and JSON on the cluster, with the same structure. Every version of persistent://shop/orders/created's schema is deleted and the document's 1 uploaded: producers and consumers holding the old schema are refused until they use the new one, and the versions are numbered anew. JSON to AVRO is not a conversion: messages already on the topic stay encoded as JSON, and a client still on the JSON schema cannot produce or read alongside one on AVRO.
± replace persistent://shop/orders/paid history 1 version(s) -> 1 version(s) [soft-deletes the subject's versions]
The versions of persistent://shop/orders/paid's schema differ: the document's 1 are not the cluster's 1, in order. Every version of persistent://shop/orders/paid's schema is deleted and the document's 1 uploaded: producers and consumers holding the old schema are refused until they use the new one, and the versions are numbered anew.
± replace persistent://shop/orders/raw schemaType AVRO -> JSON [soft-deletes the subject's versions]
The schema of persistent://shop/orders/raw is JSON in the document and AVRO on the cluster, with the same structure. Every version of persistent://shop/orders/raw's schema is deleted and the document's 1 uploaded: producers and consumers holding the old schema are refused until they use the new one, and the versions are numbered anew. AVRO to JSON is not a conversion: messages already on the topic stay encoded as AVRO, and a client still on the AVRO schema cannot produce or read alongside one on JSON.
± replace persistent://shop/orders/shipped schemaType AVRO -> PROTOBUF [soft-deletes the subject's versions]
The schema of persistent://shop/orders/shipped is PROTOBUF in the document and AVRO on the cluster, and their structures differ. Every version of persistent://shop/orders/shipped's schema is deleted and the document's 1 uploaded: producers and consumers holding the old schema are refused until they use the new one, and the versions are numbered anew.
note: Pulsar checks each schema version against the compatibility in force, and deletes a topic's schema only whole: undoing an append re-uploads the versions there were.
note: persistent://shop/orders/created's schema goes from JSON to AVRO: sync converts no schema and no message, so what is on the topic stays JSON.
note: persistent://shop/orders/raw's schema goes from AVRO to JSON: sync converts no schema and no message, so what is on the topic stays AVRO.
left alone (1)
and 1 difference sync does not act on - servers, messages, undeclared settings; kurkik pulsar diff shows them
applying needs: tenant admin on shop
4 changes, 4 destroy
Apache Pulsar has no rehearsal: the plan above is all of it. Nothing was changed.
exit 2
$ kurkik pulsar sync a.yaml b --schemas --overwrite --replace-schemas --yes
Sync a.yaml into b - Apache Pulsar, cluster b (http://pulsar-b:8080)
owns: namespaces shop/orders - the ones its channels live in; permissions, as x-kurkik.pulsar.server.acl declares them
plan: <digest>
Run one sync per cluster at a time: two at once each plan against a state the other is changing.
changes (4)
± replace persistent://shop/orders/created schemaType JSON -> AVRO [soft-deletes the subject's versions]
The schema of persistent://shop/orders/created is AVRO in the document and JSON on the cluster, with the same structure. Every version of persistent://shop/orders/created's schema is deleted and the document's 1 uploaded: producers and consumers holding the old schema are refused until they use the new one, and the versions are numbered anew. JSON to AVRO is not a conversion: messages already on the topic stay encoded as JSON, and a client still on the JSON schema cannot produce or read alongside one on AVRO.
± replace persistent://shop/orders/paid history 1 version(s) -> 1 version(s) [soft-deletes the subject's versions]
The versions of persistent://shop/orders/paid's schema differ: the document's 1 are not the cluster's 1, in order. Every version of persistent://shop/orders/paid's schema is deleted and the document's 1 uploaded: producers and consumers holding the old schema are refused until they use the new one, and the versions are numbered anew.
± replace persistent://shop/orders/raw schemaType AVRO -> JSON [soft-deletes the subject's versions]
The schema of persistent://shop/orders/raw is JSON in the document and AVRO on the cluster, with the same structure. Every version of persistent://shop/orders/raw's schema is deleted and the document's 1 uploaded: producers and consumers holding the old schema are refused until they use the new one, and the versions are numbered anew. AVRO to JSON is not a conversion: messages already on the topic stay encoded as AVRO, and a client still on the AVRO schema cannot produce or read alongside one on JSON.
± replace persistent://shop/orders/shipped schemaType AVRO -> PROTOBUF [soft-deletes the subject's versions]
The schema of persistent://shop/orders/shipped is PROTOBUF in the document and AVRO on the cluster, and their structures differ. Every version of persistent://shop/orders/shipped's schema is deleted and the document's 1 uploaded: producers and consumers holding the old schema are refused until they use the new one, and the versions are numbered anew.
note: Pulsar checks each schema version against the compatibility in force, and deletes a topic's schema only whole: undoing an append re-uploads the versions there were.
note: persistent://shop/orders/created's schema goes from JSON to AVRO: sync converts no schema and no message, so what is on the topic stays JSON.
note: persistent://shop/orders/raw's schema goes from AVRO to JSON: sync converts no schema and no message, so what is on the topic stays AVRO.
left alone (1)
and 1 difference sync does not act on - servers, messages, undeclared settings; kurkik pulsar diff shows them
applying needs: tenant admin on shop
4 changes, 4 destroy
applied
[+] done replace persistent://shop/orders/created schemaType JSON -> AVRO
[+] done replace persistent://shop/orders/paid history 1 version(s) -> 1 version(s)
[+] done replace persistent://shop/orders/raw schemaType AVRO -> JSON
[+] done replace persistent://shop/orders/shipped schemaType AVRO -> PROTOBUF
Applied 4 of 4 changes - 1 left alone
snapshot: ~/.local/state/kurkik/sync/b/b-<time>.snapshot.yaml
rollback: ~/.local/state/kurkik/sync/b/b-<time>.rollback.yaml
undo: kurkik pulsar sync revert ~/.local/state/kurkik/sync/b/b-<time>.snapshot.yaml
exit 0

Written before the first change.

rollback.yaml
system: "Apache Pulsar"
target: "b (http://pulsar-b:8080)"
createdAt: "<time>"
document: "~/.local/state/kurkik/sync/b/b-<time>.snapshot.yaml"
entries:
- forAction: "replace-schemas:persistent://shop/orders/created:schemaType"
undo: "RESTORE_REPLACED_SCHEMAS"
target: "persistent://shop/orders/created"
field: "schemaType"
note: "sync replaced this subject's versions. Undoing it soft-deletes the ones it\
\ registered and registers the old ones again, in order, under new version numbers."
definition:
before: "[\"{\\\"type\\\":\\\"record\\\",\\\"name\\\":\\\"Order\\\",\\\"namespace\\\
\":\\\"shop\\\",\\\"fields\\\":[{\\\"name\\\":\\\"id\\\",\\\"type\\\":\\\"string\\\
\"},{\\\"name\\\":\\\"total\\\",\\\"type\\\":\\\"double\\\"}]}\"]"
beforeType: "JSON"
expect: "[\"{\\\"type\\\":\\\"record\\\",\\\"name\\\":\\\"Order\\\",\\\"namespace\\\
\":\\\"shop\\\",\\\"fields\\\":[{\\\"name\\\":\\\"id\\\",\\\"type\\\":\\\"string\\\
\"},{\\\"name\\\":\\\"total\\\",\\\"type\\\":\\\"double\\\"}]}\"]"
type: "AVRO"
versions: "[\"{\\\"type\\\":\\\"record\\\",\\\"name\\\":\\\"Order\\\",\\\"namespace\\\
\":\\\"shop\\\",\\\"fields\\\":[{\\\"name\\\":\\\"id\\\",\\\"type\\\":\\\"string\\\
\"},{\\\"name\\\":\\\"total\\\",\\\"type\\\":\\\"double\\\"}]}\"]"
- forAction: "replace-schemas:persistent://shop/orders/paid:history"
undo: "RESTORE_REPLACED_SCHEMAS"
target: "persistent://shop/orders/paid"
field: "history"
note: "sync replaced this subject's versions. Undoing it soft-deletes the ones it\
\ registered and registers the old ones again, in order, under new version numbers."
definition:
before: "[\"{\\\"type\\\":\\\"record\\\",\\\"name\\\":\\\"Payment\\\",\\\"namespace\\\
\":\\\"shop\\\",\\\"fields\\\":[{\\\"name\\\":\\\"order\\\",\\\"type\\\":\\\"\
string\\\"},{\\\"name\\\":\\\"paid\\\",\\\"type\\\":\\\"boolean\\\"},{\\\"name\\\
\":\\\"at\\\",\\\"type\\\":\\\"long\\\"}]}\"]"
beforeType: "AVRO"
expect: "[\"{\\\"type\\\":\\\"record\\\",\\\"name\\\":\\\"Payment\\\",\\\"namespace\\\
\":\\\"shop\\\",\\\"fields\\\":[{\\\"name\\\":\\\"order\\\",\\\"type\\\":\\\"\
string\\\"},{\\\"name\\\":\\\"paid\\\",\\\"type\\\":\\\"boolean\\\"}]}\"]"
type: "AVRO"
versions: "[\"{\\\"type\\\":\\\"record\\\",\\\"name\\\":\\\"Payment\\\",\\\"namespace\\\
\":\\\"shop\\\",\\\"fields\\\":[{\\\"name\\\":\\\"order\\\",\\\"type\\\":\\\"\
string\\\"},{\\\"name\\\":\\\"paid\\\",\\\"type\\\":\\\"boolean\\\"}]}\"]"
- forAction: "replace-schemas:persistent://shop/orders/raw:schemaType"
undo: "RESTORE_REPLACED_SCHEMAS"
target: "persistent://shop/orders/raw"
field: "schemaType"
note: "sync replaced this subject's versions. Undoing it soft-deletes the ones it\
\ registered and registers the old ones again, in order, under new version numbers."
definition:
before: "[\"{\\\"type\\\":\\\"record\\\",\\\"name\\\":\\\"Order\\\",\\\"namespace\\\
\":\\\"shop\\\",\\\"fields\\\":[{\\\"name\\\":\\\"id\\\",\\\"type\\\":\\\"string\\\
\"},{\\\"name\\\":\\\"total\\\",\\\"type\\\":\\\"double\\\"}]}\"]"
beforeType: "AVRO"
expect: "[\"{\\\"type\\\":\\\"record\\\",\\\"name\\\":\\\"Order\\\",\\\"namespace\\\
\":\\\"shop\\\",\\\"fields\\\":[{\\\"name\\\":\\\"id\\\",\\\"type\\\":\\\"string\\\
\"},{\\\"name\\\":\\\"total\\\",\\\"type\\\":\\\"double\\\"}]}\"]"
type: "JSON"
versions: "[\"{\\\"type\\\":\\\"record\\\",\\\"name\\\":\\\"Order\\\",\\\"namespace\\\
\":\\\"shop\\\",\\\"fields\\\":[{\\\"name\\\":\\\"id\\\",\\\"type\\\":\\\"string\\\
\"},{\\\"name\\\":\\\"total\\\",\\\"type\\\":\\\"double\\\"}]}\"]"
- forAction: "replace-schemas:persistent://shop/orders/shipped:schemaType"
undo: "RESTORE_REPLACED_SCHEMAS"
target: "persistent://shop/orders/shipped"
field: "schemaType"
note: "sync replaced this subject's versions. Undoing it soft-deletes the ones it\
\ registered and registers the old ones again, in order, under new version numbers."
definition:
before: "[\"{\\\"type\\\":\\\"record\\\",\\\"name\\\":\\\"Payment\\\",\\\"namespace\\\
\":\\\"shop\\\",\\\"fields\\\":[{\\\"name\\\":\\\"order\\\",\\\"type\\\":\\\"\
string\\\"},{\\\"name\\\":\\\"paid\\\",\\\"type\\\":\\\"boolean\\\"}]}\"]"
beforeType: "AVRO"
expect: "[\"{\\\"type\\\":\\\"record\\\",\\\"name\\\":\\\"Shipment\\\",\\\"namespace\\\
\":\\\"shop\\\",\\\"fields\\\":[{\\\"name\\\":\\\"id\\\",\\\"type\\\":\\\"string\\\
\"},{\\\"name\\\":\\\"carrier\\\",\\\"type\\\":\\\"string\\\"}]}\"]"
type: "PROTOBUF"
versions: "[\"{\\\"type\\\":\\\"record\\\",\\\"name\\\":\\\"Shipment\\\",\\\"\
namespace\\\":\\\"shop\\\",\\\"fields\\\":[{\\\"name\\\":\\\"id\\\",\\\"type\\\
\":\\\"string\\\"},{\\\"name\\\":\\\"carrier\\\",\\\"type\\\":\\\"string\\\"\
}]}\"]"

Download rollback.yaml

$ kurkik pulsar diff a.yaml b --schemas
a.yaml vs b
Notes
- Not compared: ACLs, consumers, functions, connectors, configuration. Add --acls --consumers --functions --connectors --configs, or --all, to compare them.
Drift: 0 changed · 0 unmanaged · 0 missing (no drift) - 29 matched
exit 0
$ kurkik pulsar sync revert ~/.local/state/kurkik/sync/b/b-<time>.snapshot.yaml b --force --yes
Revert b to b-<time>.snapshot.yaml - Apache Pulsar, cluster b (http://pulsar-b:8080)
owns: what the run being undone changed, as its rollback records it
plan: <digest>
Run one sync per cluster at a time: two at once each plan against a state the other is changing.
changes (4)
± replace persistent://shop/orders/shipped schemaType [soft-deletes the subject's versions]
persistent://shop/orders/shipped's schema is deleted and its 1 earlier version(s) uploaded again, numbered anew.
± replace persistent://shop/orders/raw schemaType [soft-deletes the subject's versions]
persistent://shop/orders/raw's schema is deleted and its 1 earlier version(s) uploaded again, numbered anew.
± replace persistent://shop/orders/paid history [soft-deletes the subject's versions]
persistent://shop/orders/paid's schema is deleted and its 1 earlier version(s) uploaded again, numbered anew.
± replace persistent://shop/orders/created schemaType [soft-deletes the subject's versions]
persistent://shop/orders/created's schema is deleted and its 1 earlier version(s) uploaded again, numbered anew.
note: Pulsar checks each schema version against the compatibility in force, and deletes a topic's schema only whole: undoing an append re-uploads the versions there were.
applying needs: tenant admin on shop
4 changes, 4 destroy
applied
[+] done replace persistent://shop/orders/shipped schemaType
[+] done replace persistent://shop/orders/raw schemaType
[+] done replace persistent://shop/orders/paid history
[+] done replace persistent://shop/orders/created schemaType
Applied 4 of 4 changes
snapshot: ~/.local/state/kurkik/sync/b/b-<time>.snapshot.yaml
rollback: ~/.local/state/kurkik/sync/b/b-<time>.rollback.yaml
undo: kurkik pulsar sync revert ~/.local/state/kurkik/sync/b/b-<time>.snapshot.yaml
exit 0

After the revert, compared with how it was before: Drift: 0 changed · 0 unmanaged · 0 missing (no drift) - 66 matched

source.yaml, 346 lines
asyncapi: 3.0.0
info:
title: a Apache Pulsar API
version: 1.0.0-SNAPSHOT
description: Generated by reading Apache Pulsar of a (http://pulsar-a:8080).
servers:
standalone:
host: pulsar-a: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://pulsar-a:8080
schemaRegistryVendor: pulsar
namespacePolicies:
public/default:
schema-autoupdate: "on"
shop/orders:
schema-autoupdate: "on"
tenants:
- tenant: public
adminRoles: []
allowedClusters:
- standalone
- tenant: shop
adminRoles:
- shop-admin
allowedClusters:
- standalone
security:
- security: NONE
tls: false
acl: []
consumers: []
producers: []
functions: []
sources: []
sinks: []
brokerConfiguration:
advertisedAddress: localhost
backlogQuotaDefaultLimitGB: "10.0"
bookkeeperClientMinNumRacksPerWriteQuorum: "1"
bookkeeperClientReorderReadSequenceEnabled: "false"
bookkeeperNumberOfChannelsPerBookie: "1"
brokerDeleteInactiveTopicsEnabled: "false"
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-a:6650
webServiceUrl: http://pulsar-a: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 Pulsar's own registry: AVRO, version 0."
x-kurkik:
pulsar:
message:
schemaType: AVRO
schemaVersion: 0
schemaIdLocation: metadata
schemaLookupStrategy: topic
schemaCompatibility: FULL
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
messages:
persistent-shop-orders-paid:
payload:
schemaFormat: application/vnd.apache.avro;version=1.9.0
schema:
type: record
name: Payment
namespace: shop
fields:
- name: order
type: string
- name: paid
type: boolean
name: persistent-shop-orders-paid
title: persistent://shop/orders/paid
summary: "Schema read from Pulsar's own registry: AVRO, version 0."
x-kurkik:
pulsar:
message:
schemaType: AVRO
schemaVersion: 0
schemaIdLocation: metadata
schemaLookupStrategy: topic
schemaCompatibility: FULL
key:
type: string
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"
persistent-shop-orders-raw:
address: persistent://shop/orders/raw
messages:
persistent-shop-orders-raw:
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-raw
title: persistent://shop/orders/raw
summary: "Schema read from Pulsar's own registry: JSON, version 0."
x-kurkik:
pulsar:
message:
schemaType: JSON
schemaVersion: 0
schemaIdLocation: metadata
schemaLookupStrategy: topic
schemaCompatibility: FULL
key:
type: string
bindings:
pulsar:
bindingVersion: 0.1.0
namespace: orders
persistence: persistent
x-kurkik:
pulsar:
channel:
topic: persistent://shop/orders/raw
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-shipped:
address: persistent://shop/orders/shipped
messages:
persistent-shop-orders-shipped:
payload:
schemaFormat: application/vnd.apache.avro;version=1.9.0
schema:
type: record
name: Shipment
namespace: shop
fields:
- name: id
type: string
- name: carrier
type: string
name: persistent-shop-orders-shipped
title: persistent://shop/orders/shipped
summary: "Schema read from Pulsar's own registry: PROTOBUF, version 0."
x-kurkik:
pulsar:
message:
schemaType: PROTOBUF
schemaVersion: 0
schemaIdLocation: metadata
schemaLookupStrategy: topic
schemaCompatibility: FULL
key:
type: string
bindings:
pulsar:
bindingVersion: 0.1.0
namespace: orders
persistence: persistent
x-kurkik:
pulsar:
channel:
topic: persistent://shop/orders/shipped
tenant: shop
namespace: orders
persistence: persistent
partitions: 0
geo-replication:
- standalone
topicConfiguration:
partitions: 0
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:
security: []
consumerConfiguration: {}
receive_persistent-shop-orders-paid:
action: receive
channel:
$ref: "#/channels/persistent-shop-orders-paid"
x-kurkik:
pulsar:
operation:
security: []
consumerConfiguration: {}
receive_persistent-shop-orders-raw:
action: receive
channel:
$ref: "#/channels/persistent-shop-orders-raw"
x-kurkik:
pulsar:
operation:
security: []
consumerConfiguration: {}
receive_persistent-shop-orders-shipped:
action: receive
channel:
$ref: "#/channels/persistent-shop-orders-shipped"
x-kurkik:
pulsar:
operation:
security: []
consumerConfiguration: {}
send_persistent-shop-orders-created:
action: send
channel:
$ref: "#/channels/persistent-shop-orders-created"
x-kurkik:
pulsar:
operation:
security: []
producerConfiguration: {}
send_persistent-shop-orders-paid:
action: send
channel:
$ref: "#/channels/persistent-shop-orders-paid"
x-kurkik:
pulsar:
operation:
security: []
producerConfiguration: {}
send_persistent-shop-orders-raw:
action: send
channel:
$ref: "#/channels/persistent-shop-orders-raw"
x-kurkik:
pulsar:
operation:
security: []
producerConfiguration: {}
send_persistent-shop-orders-shipped:
action: send
channel:
$ref: "#/channels/persistent-shop-orders-shipped"
x-kurkik:
pulsar:
operation:
security: []
producerConfiguration: {}

Download source.yaml

target.yaml, 348 lines
asyncapi: 3.0.0
info:
title: b Apache Pulsar API
version: 1.0.0-SNAPSHOT
description: Generated by reading Apache Pulsar of b (http://pulsar-b:8080).
servers:
standalone:
host: pulsar-b: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://pulsar-b:8080
schemaRegistryVendor: pulsar
namespacePolicies:
public/default:
schema-autoupdate: "on"
shop/orders:
schema-autoupdate: "on"
tenants:
- tenant: public
adminRoles: []
allowedClusters:
- standalone
- tenant: shop
adminRoles:
- shop-admin
allowedClusters:
- standalone
security:
- security: NONE
tls: false
acl: []
consumers: []
producers: []
functions: []
sources: []
sinks: []
brokerConfiguration:
advertisedAddress: localhost
backlogQuotaDefaultLimitGB: "10.0"
bookkeeperClientMinNumRacksPerWriteQuorum: "1"
bookkeeperClientReorderReadSequenceEnabled: "false"
bookkeeperNumberOfChannelsPerBookie: "1"
brokerDeleteInactiveTopicsEnabled: "false"
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-b:6650
webServiceUrl: http://pulsar-b: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 Pulsar's own registry: JSON, version 0."
x-kurkik:
pulsar:
message:
schemaType: JSON
schemaVersion: 0
schemaIdLocation: metadata
schemaLookupStrategy: topic
schemaCompatibility: FULL
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
messages:
persistent-shop-orders-paid:
payload:
schemaFormat: application/vnd.apache.avro;version=1.9.0
schema:
type: record
name: Payment
namespace: shop
fields:
- name: order
type: string
- name: paid
type: boolean
- name: at
type: long
name: persistent-shop-orders-paid
title: persistent://shop/orders/paid
summary: "Schema read from Pulsar's own registry: AVRO, version 0."
x-kurkik:
pulsar:
message:
schemaType: AVRO
schemaVersion: 0
schemaIdLocation: metadata
schemaLookupStrategy: topic
schemaCompatibility: FULL
key:
type: string
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"
persistent-shop-orders-raw:
address: persistent://shop/orders/raw
messages:
persistent-shop-orders-raw:
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-raw
title: persistent://shop/orders/raw
summary: "Schema read from Pulsar's own registry: AVRO, version 0."
x-kurkik:
pulsar:
message:
schemaType: AVRO
schemaVersion: 0
schemaIdLocation: metadata
schemaLookupStrategy: topic
schemaCompatibility: FULL
key:
type: string
bindings:
pulsar:
bindingVersion: 0.1.0
namespace: orders
persistence: persistent
x-kurkik:
pulsar:
channel:
topic: persistent://shop/orders/raw
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-shipped:
address: persistent://shop/orders/shipped
messages:
persistent-shop-orders-shipped:
payload:
schemaFormat: application/vnd.apache.avro;version=1.9.0
schema:
type: record
name: Payment
namespace: shop
fields:
- name: order
type: string
- name: paid
type: boolean
name: persistent-shop-orders-shipped
title: persistent://shop/orders/shipped
summary: "Schema read from Pulsar's own registry: AVRO, version 0."
x-kurkik:
pulsar:
message:
schemaType: AVRO
schemaVersion: 0
schemaIdLocation: metadata
schemaLookupStrategy: topic
schemaCompatibility: FULL
key:
type: string
bindings:
pulsar:
bindingVersion: 0.1.0
namespace: orders
persistence: persistent
x-kurkik:
pulsar:
channel:
topic: persistent://shop/orders/shipped
tenant: shop
namespace: orders
persistence: persistent
partitions: 0
geo-replication:
- standalone
topicConfiguration:
partitions: 0
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:
security: []
consumerConfiguration: {}
receive_persistent-shop-orders-paid:
action: receive
channel:
$ref: "#/channels/persistent-shop-orders-paid"
x-kurkik:
pulsar:
operation:
security: []
consumerConfiguration: {}
receive_persistent-shop-orders-raw:
action: receive
channel:
$ref: "#/channels/persistent-shop-orders-raw"
x-kurkik:
pulsar:
operation:
security: []
consumerConfiguration: {}
receive_persistent-shop-orders-shipped:
action: receive
channel:
$ref: "#/channels/persistent-shop-orders-shipped"
x-kurkik:
pulsar:
operation:
security: []
consumerConfiguration: {}
send_persistent-shop-orders-created:
action: send
channel:
$ref: "#/channels/persistent-shop-orders-created"
x-kurkik:
pulsar:
operation:
security: []
producerConfiguration: {}
send_persistent-shop-orders-paid:
action: send
channel:
$ref: "#/channels/persistent-shop-orders-paid"
x-kurkik:
pulsar:
operation:
security: []
producerConfiguration: {}
send_persistent-shop-orders-raw:
action: send
channel:
$ref: "#/channels/persistent-shop-orders-raw"
x-kurkik:
pulsar:
operation:
security: []
producerConfiguration: {}
send_persistent-shop-orders-shipped:
action: send
channel:
$ref: "#/channels/persistent-shop-orders-shipped"
x-kurkik:
pulsar:
operation:
security: []
producerConfiguration: {}

Download target.yaml

How to build this setup yourself

Clusters

Pulsar a

Terminal window
pulsar-admin --admin-url http://pulsar-a:8080 tenants create shop --allowed-clusters standalone --admin-roles shop-admin
pulsar-admin --admin-url http://pulsar-a:8080 namespaces create shop/orders --clusters standalone
pulsar-admin --admin-url http://pulsar-a:8080 topics create persistent://shop/orders/created
pulsar-admin --admin-url http://pulsar-a:8080 topics create-partitioned-topic persistent://shop/orders/paid --partitions 2
pulsar-admin --admin-url http://pulsar-a:8080 topics create persistent://shop/orders/shipped
pulsar-admin --admin-url http://pulsar-a:8080 topics create persistent://shop/orders/raw
pulsar-admin --admin-url http://pulsar-a:8080 schemas upload persistent://shop/orders/created -f schema.json # {"type": "AVRO", "schema": "{\"type\":\"record\",\"name\":\"Order\",\"namespace\":\"shop\",\"fields\":[{\"name\":\"id\",\"type\":\"string\"},{\"name\":\"total\",\"type\":\"double\"}]}"}
pulsar-admin --admin-url http://pulsar-a:8080 schemas upload persistent://shop/orders/raw -f schema.json # {"type": "JSON", "schema": "{\"type\":\"record\",\"name\":\"Order\",\"namespace\":\"shop\",\"fields\":[{\"name\":\"id\",\"type\":\"string\"},{\"name\":\"total\",\"type\":\"double\"}]}"}
pulsar-admin --admin-url http://pulsar-a:8080 schemas upload persistent://shop/orders/shipped -f schema.json # {"type": "PROTOBUF", "schema": "{\"type\":\"record\",\"name\":\"Shipment\",\"namespace\":\"shop\",\"fields\":[{\"name\":\"id\",\"type\":\"string\"},{\"name\":\"carrier\",\"type\":\"string\"}]}"}
pulsar-admin --admin-url http://pulsar-a:8080 schemas upload persistent://shop/orders/paid -f schema.json # {"type": "AVRO", "schema": "{\"type\":\"record\",\"name\":\"Payment\",\"namespace\":\"shop\",\"fields\":[{\"name\":\"order\",\"type\":\"string\"},{\"name\":\"paid\",\"type\":\"boolean\"}]}"}

Pulsar b

Terminal window
pulsar-admin --admin-url http://pulsar-b:8080 tenants create shop --allowed-clusters standalone --admin-roles shop-admin
pulsar-admin --admin-url http://pulsar-b:8080 namespaces create shop/orders --clusters standalone
pulsar-admin --admin-url http://pulsar-b:8080 topics create persistent://shop/orders/created
pulsar-admin --admin-url http://pulsar-b:8080 topics create-partitioned-topic persistent://shop/orders/paid --partitions 2
pulsar-admin --admin-url http://pulsar-b:8080 topics create persistent://shop/orders/shipped
pulsar-admin --admin-url http://pulsar-b:8080 topics create persistent://shop/orders/raw
pulsar-admin --admin-url http://pulsar-b:8080 schemas upload persistent://shop/orders/created -f schema.json # {"type": "JSON", "schema": "{\"type\":\"record\",\"name\":\"Order\",\"namespace\":\"shop\",\"fields\":[{\"name\":\"id\",\"type\":\"string\"},{\"name\":\"total\",\"type\":\"double\"}]}"}
pulsar-admin --admin-url http://pulsar-b:8080 schemas upload persistent://shop/orders/raw -f schema.json # {"type": "AVRO", "schema": "{\"type\":\"record\",\"name\":\"Order\",\"namespace\":\"shop\",\"fields\":[{\"name\":\"id\",\"type\":\"string\"},{\"name\":\"total\",\"type\":\"double\"}]}"}
pulsar-admin --admin-url http://pulsar-b:8080 schemas upload persistent://shop/orders/shipped -f schema.json # {"type": "AVRO", "schema": "{\"type\":\"record\",\"name\":\"Payment\",\"namespace\":\"shop\",\"fields\":[{\"name\":\"order\",\"type\":\"string\"},{\"name\":\"paid\",\"type\":\"boolean\"}]}"}
pulsar-admin --admin-url http://pulsar-b:8080 schemas upload persistent://shop/orders/paid -f schema.json # {"type": "AVRO", "schema": "{\"type\":\"record\",\"name\":\"Payment\",\"namespace\":\"shop\",\"fields\":[{\"name\":\"order\",\"type\":\"string\"},{\"name\":\"paid\",\"type\":\"boolean\"},{\"name\":\"at\",\"type\":\"long\"}]}"}

Sync

Terminal window
kurkik conn add pulsar a --admin-url http://pulsar-a:8080 --service-url pulsar://pulsar-a:6650 --client 4.0
kurkik conn add pulsar b --admin-url http://pulsar-b:8080 --service-url pulsar://pulsar-b:6650 --client 4.0
kurkik pulsar export a --this-cluster-only --acls --consumers --stdout > a.yaml # source.yaml (and b's, before: target.yaml)
kurkik pulsar sync a.yaml b --schemas --dry-run # plan-without.txt
kurkik pulsar sync a.yaml b --schemas --overwrite --replace-schemas --dry-run # plan.txt (and -o json: plan.json)
kurkik pulsar sync a.yaml b --schemas --overwrite --replace-schemas --yes # apply.txt, and the reverse patch: rollback.yaml
kurkik pulsar diff a.yaml b --schemas # after.txt
kurkik pulsar sync revert ~/.local/state/kurkik/sync/b/b-<time>.snapshot.yaml b --force --yes # revert.txt

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