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

${cause}

Error message

${cause}

What it means

Thrown by MultiTopicQueueConsumer.close() when closeAsync()'s future completed exceptionally. The original failure is unwrapped from ExecutionException and rethrown as a PulsarClientException with the cause attached. It surfaces any error that occurred while closing per-topic consumers.

Source

Thrown at pulsar-client-v5/src/main/java/org/apache/pulsar/client/impl/v5/MultiTopicQueueConsumer.java:362

            return;
        }
        action.accept(state.consumer);
    }

    @Override
    public AsyncQueueConsumer<T> async() {
        return asyncView;
    }

    @Override
    public void close() throws PulsarClientException {
        try {
            closeAsync().get();
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
            throw new PulsarClientException("Close interrupted", e);
        } catch (ExecutionException e) {
            throw new PulsarClientException(e.getCause());
        }
    }

    @Override
    public CompletableFuture<Message<T>> receiveAsync() {
        return mux.receiveAsync();
    }

    @Override
    public CompletableFuture<Void> closeAsync() {
        if (closed) {
            return CompletableFuture.completedFuture(null);
        }
        closed = true;
        watcher.close();
        mux.close();
        // Cancel pending retries for topics that never finished subscribing (they're not in
        // perTopic, so the closeTopic loop below wouldn't reach them).

View on GitHub (pinned to 820761864e)

Solutions

  1. Inspect e.getCause() (the PulsarClientException) to identify the failing topic/consumer
  2. Retry close() once the connection is re-established; close is generally idempotent-safe to retry
  3. Use closeAsync() and log per-topic failures instead of letting close() throw

Example fix

// before
consumer.close(); // may throw with opaque cause
// after
try {
    consumer.close();
} catch (PulsarClientException e) {
    log.warn("close failed: {}", e.getCause(), e);
}
Defensive patterns

Strategy: try-catch

Try / catch

try { consumer.close(); } catch (PulsarClientException e) { log.warn("close failed: {}", e.getCause()); }

Prevention

When it happens

Trigger: closeAsync() fails because an underlying per-topic consumer or client throws during close — broker connection lost, per-topic close errors, or subscription close failures.

Common situations: Closing consumers during a broker outage or network partition; client already closed; timeouts on the broker while unsubscribing.

Related errors


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