Introduction to the Pulsar Java Client V5 API
masterThe Pulsar Java Client V5 API is a new, non-breaking replacement for the existing pulsar-client-api. It is designed to support Scalable Topics (where topic segments are managed dynamically by the broker) and provides a cleaner, more type-safe interface by separating different consumption models into distinct consumer types.
Key improvements include:
- Opaque Topic Model: Removes partitioning details (like partition indexes) from the client API, treating topics as single endpoints.
- Purpose-built Consumers: Replaces the single
Consumerinterface with specialized types for streaming, queuing, and checkpointing. - Modern Java Idioms: Uses
Duration,Instant,Optional, andServiceLoaderinstead of legacy patterns. - Side-by-side Coexistence: The V5 API is shipped in new modules (
pulsar-client-api-v5andpulsar-client-v5) and can coexist with the existing v4 client in the same JVM.
<!-- Dependency structure -->
<dependency>
<groupId>org.apache.pulsar</groupId>
<artifactId>pulsar-client-api-v5</artifactId>
</dependency>
<dependency>
<groupId>org.apache.pulsar</groupId>
<artifactId>pulsar-client-v5</artifactId>
</dependency>