apache/pulsar · error · org.apache.pulsar.client.impl.v5.PulsarClientException.NotFoundException

${cause.getMessage()}

Error message

${cause.getMessage()}

What it means

Thrown by ProducerBuilderV5.create() when the underlying async producer creation completes exceptionally. PulsarClientException subtypes are rethrown as-is; any other cause is wrapped in a plain PulsarClientException (or NotFoundException when it matches). The message is the cause's message.

Source

Thrown at pulsar-client-v5/src/main/java/org/apache/pulsar/client/impl/v5/ProducerBuilderV5.java:63

    private final Schema<T> v5Schema;
    private final ProducerConfigurationData conf = new ProducerConfigurationData();

    ProducerBuilderV5(PulsarClientV5 client, Schema<T> v5Schema) {
        this.client = client;
        this.v5Schema = v5Schema;
    }

    @Override
    public Producer<T> create() throws PulsarClientException {
        try {
            return createAsync().join();
        } catch (java.util.concurrent.CompletionException e) {
            Throwable cause = e.getCause();
            if (cause instanceof PulsarClientException pce) {
                throw pce;
            }
            if (cause instanceof org.apache.pulsar.client.api.PulsarClientException.NotFoundException) {
                throw new PulsarClientException.NotFoundException(cause.getMessage());
            }
            throw new PulsarClientException(cause);
        }
    }

    @Override
    public CompletableFuture<Producer<T>> createAsync() {
        String topicStr = conf.getTopicName();
        if (topicStr == null || topicStr.isEmpty()) {
            return CompletableFuture.failedFuture(
                    new PulsarClientException.InvalidConfigurationException("Topic name is required"));
        }

        TopicName topicName = V5Utils.parseScalableTopicInput(topicStr);

        // Create DAG watch client and start the session
        DagWatchClient dagWatch = new DagWatchClient(client.v4Client(), topicName);

View on GitHub (pinned to 820761864e)

Solutions

  1. Read the wrapped cause message to identify the root failure
  2. Verify the topic name and serviceUrl configuration
  3. Check auth plugin/credentials are set correctly
  4. Enable topic auto-creation or create the topic before producing

Example fix

// before
Producer<String> p = client.newProducer(Schema.STRING).create();
// after
try {
    Producer<String> p = client.newProducer(Schema.STRING).topic(topic).create();
} catch (PulsarClientException.NotFoundException e) {
    // topic does not exist — create it or enable auto-creation
}
Defensive patterns

Strategy: try-catch

Validate before calling

// validate before create
Objects.requireNonNull(topic, "topic required");
if (!topic.startsWith("persistent://") && !topic.startsWith("non-persistent://") && !topic.matches("[\w/-]+")) { throw new IllegalArgumentException("bad topic: " + topic); }

Try / catch

try { producer = builder.create(); } catch (PulsarClientException.NotFoundException e) { /* topic missing */ } catch (PulsarClientException e) { log.error("producer create failed: {}", e.getMessage()); }

Prevention

When it happens

Trigger: create() called on a builder whose async path failed — invalid topic name, broker unreachable, authentication failure, namespace/topic not found, or producer name conflicts.

Common situations: Typo in topic URL; broker down or wrong serviceUrl; missing auth credentials; topic auto-creation disabled and topic absent.

Related errors


AI-assisted analysis of apache/pulsar@820761864e (2026-09-06). Data as JSON: /api/errors/150a570314658019. Report an issue: GitHub.