{% include admonition.html type=“success” title=‘Notice’ content=" This feature is still in experimental mode and implementation details may change in future release. " %}
As name suggests, non-persist topic does not persist messages into any durable storage disk unlike persistent topic where messages are durably persisted on multiple disks.
Therefore, if you are using persistent delivery, messages are persisted to disk/database so that they will survive a broker restart or subscriber failover. While using non-persistent delivery, if you kill a broker or subscriber is disconnected then subscriber will lose all in-transit messages. So, client may see message loss with non-persistent topic.
msg-id: -1:-1
) for those dropped messages to signal producer about the message drop.Non-persistent messaging is usually faster than persistent messaging because broker does not persist messages and immediately sends ack back to producer as soon as that message deliver to all connected subscribers. Therefore, producer sees comparatively low publish latency with non-persistent topic.
A topic name will look like:
non-persistent://my-property/us-west/my-namespace/my-topic
Producer and consumer can connect to non-persistent topic in a similar way, as persistent topic except topic name must start with non-persistent
.
Non-persistent topic supports all 3 different subscription-modes: Exclusive, Shared, Failover which are already explained in details at GettingStarted.
PulsarClient client = PulsarClient.create("pulsar://localhost:6650"); Consumer consumer = client.subscribe( "non-persistent://sample/standalone/ns1/my-topic", "my-subscribtion-name");
PulsarClient client = PulsarClient.create("pulsar://localhost:6650"); Producer producer = client.createProducer( "non-persistent://sample/standalone/ns1/my-topic");
Sometimes, there would be a need to configure few dedicated brokers in a cluster, to just serve non-persistent topics.
Broker configuration for enabling broker to own only configured type of topics
# It disables broker to load persistent topics enablePersistentTopics=false # It enables broker to load non-persistent topics enableNonPersistentTopics=true