Installation
Add the Pulsar Java client to your project:The Java client requires Java 17 or later. Check the version compatibility table for your Pulsar version.
Quick start
Here’s a complete example that creates a producer and consumer:Creating a client
ThePulsarClient is the entry point for all operations:
Producing messages
Basic producer
Producer with properties
Sending with properties
Consuming messages
Basic consumer
Consumer with message listener
Batch receive
Using readers
Readers allow you to read messages from a specific position:Working with schemas
Pulsar provides built-in schemas for common types:Custom POJO schemas
Authentication
TLS authentication
Token authentication
OAuth 2.0 authentication
Performance tuning
For optimal performance, configure these JVM options:Producer tuning
Consumer tuning
Error handling
Next steps
ClientBuilder API
Full client configuration reference
Producer API
Complete producer API documentation
Consumer API
Complete consumer API documentation
Schema API
Working with schemas