Java SDK
The OpenMetadata Java SDK provides a robust client library for Java applications to interact with the OpenMetadata API. It offers support for entity management, search, lineage, and authentication with a JWT token.Installation
Maven
Add the OpenMetadata Java SDK dependency to yourpom.xml:
Gradle
Add the dependency to yourbuild.gradle:
Quick Start
Basic Connection
Core Functionality
Working with Entities
Every entity type has a service on the client, such asclient.databaseServices(), client.tables(), and client.users(). These services offer methods such as create, get, getByName, list, update, delete, and restore.
Database Services
Tables
Entity Operations
CRUD Operations
Search and Filtering
Advanced Features
Authentication
The Java SDK authenticates with a JWT access token. When your token changes, create a new client with the new token:Error Handling
Async Operations
The service methods are blocking. To run them in parallel, wrap them in aCompletableFuture:
Configuration Options
Client Configuration
Common Use Cases
Metadata Discovery
Bulk Operations
Lineage Operations
Use the Client in Your Application
Create oneOpenMetadataClient and share it across your application. If you use a framework such as Spring Boot, register the client as a singleton bean.
Best Practices
- Reuse the client: Create one client and share it instead of creating a new one per request.
- Handle errors: Catch
OpenMetadataExceptionand check the status code. - Protect authentication: Keep your JWT token in a secret store, not in source code.
- Use async operations: Wrap calls in
CompletableFuturefor better performance in concurrent scenarios. - Handle pagination: Always handle pagination for large datasets.
- Cache entities: Implement caching for frequently accessed entities.
Performance Tips
- Create one client and reuse it.
- Cache frequently accessed metadata.
- Run independent calls in parallel with
CompletableFuture. - Specify only required fields when fetching entities.
- Use filters to narrow lists before you read them.