Skip to content
Latchkey

Pulsar "TopicNotFound" in CI

A consumer tried to subscribe to a topic Pulsar does not know. Producers can auto-create topics by default, but a consumer subscribing first to a non-existent topic fails with TopicNotFound, especially when the tenant or namespace also does not exist.

What this error means

A subscribe fails with "org.apache.pulsar.client.api.PulsarClientException$TopicDoesNotExistException" or "Topic not found" for a topic the producer has not created.

Terminal
org.apache.pulsar.client.api.PulsarClientException$TopicDoesNotExistException:
Topic Not Found.

Common causes

Consumer subscribed before the topic existed

No producer has created the topic yet and the consumer subscribed first, so there is nothing to subscribe to.

The tenant or namespace is missing

The fully qualified topic references a tenant/namespace that was never created, so the topic cannot exist.

How to fix it

Create the topic with pulsar-admin

Create the tenant, namespace, and topic explicitly before subscribing.

Terminal
pulsar-admin topics create persistent://public/default/orders

Allow auto-creation for the test broker

Enable topic auto-creation so a first subscribe or produce creates it.

.github/workflows/ci.yml
services:
  pulsar:
    image: apachepulsar/pulsar:3.2.0
    env:
      PULSAR_PREFIX_allowAutoTopicCreation: 'true'
    command: ["bin/pulsar", "standalone"]

How to prevent it

  • Create tenants, namespaces, and topics in a setup step.
  • Produce before consume, or enable auto-creation for tests.
  • Use fully qualified topic names that match existing namespaces.

Frequently asked questions

What causes "Pulsar "TopicNotFound""?
No producer has created the topic yet and the consumer subscribed first, so there is nothing to subscribe to.
How do I fix Pulsar "TopicNotFound"?
Create the tenant, namespace, and topic explicitly before subscribing.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card