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.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →