Skip to content

Commit 11d50ca

Browse files
authored
Update README.md
1 parent 2c61937 commit 11d50ca

File tree

1 file changed

+105
-54
lines changed

1 file changed

+105
-54
lines changed

README.md

Lines changed: 105 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,141 @@
1-
# Superstream Clients
1+
<div align="center">
22

3-
This repository contains the Superstream Clients library and example applications.
3+
<img src="https://github.com/user-attachments/assets/35899c78-24eb-4507-97ed-e87e84c49fea#gh-dark-mode-only" width="300">
4+
<img src="https://github.com/user-attachments/assets/8a7bca49-c362-4a8c-945e-a331fb26d8eb#gh-light-mode-only" width="300">
45

5-
For detailed information about the library, see the [Superstream Clients Documentation](https://github.com/superstreamlabs/superstream-clients-parent/blob/master/superstream-clients/README.md).
6+
</div>
67

7-
## Code Examples
8+
# Superstream Client For Java
89

9-
This repository includes examples showing how to use Superstream Clients with different Kafka libraries.
10+
A Java library for automatically optimizing Kafka producer configurations based on topic-specific recommendations.
1011

11-
### Running Examples
12+
## Overview
1213

13-
#### Kafka Clients Example
14+
Superstream Clients works as a Java agent that intercepts Kafka producer creation and applies optimized configurations without requiring any code changes in your application. It dynamically retrieves optimization recommendations from Superstream and applies them based on impact analysis.
1415

15-
```bash
16-
cd examples/kafka-clients-example
17-
mvn clean package
18-
export SUPERSTREAM_TOPICS_LIST=example-topic
19-
java -javaagent:../../target/superstream-clients-1.0.0.jar -jar target/kafka-clients-example-1.0.0-jar-with-dependencies.jar
20-
```
16+
## Supported Libraries
2117

22-
#### Spring Kafka Example
18+
Works with any Java library that depends on `kafka-clients`, including:
2319

24-
```bash
25-
cd examples/spring-kafka-example
26-
mvn clean package
27-
export SUPERSTREAM_TOPICS_LIST=example-topic
28-
java -javaagent:../../target/superstream-clients-1.0.0.jar -jar target/spring-kafka-example-1.0.0.jar
20+
- Apache Kafka Clients
21+
- Spring Kafka
22+
- Alpakka Kafka (Akka Kafka)
23+
- Kafka Streams
24+
- Kafka Connect
25+
- Any custom wrapper around the Kafka Java client
26+
27+
## Features
28+
29+
- **Zero-code integration**: No code changes required in your application
30+
- **Dynamic configuration**: Applies optimized settings based on topic-specific recommendations
31+
- **Intelligent optimization**: Identifies the most impactful topics to optimize
32+
- **Graceful fallback**: Falls back to default settings if optimization fails
33+
34+
## Linger Time Configuration
35+
36+
The linger.ms parameter follows these rules:
37+
38+
1. If SUPERSTREAM_LATENCY_SENSITIVE is set to true:
39+
- Linger value will never be modified, regardless of other settings
40+
41+
42+
2. If SUPERSTREAM_LATENCY_SENSITIVE is set to false or not set:
43+
- If no explicit linger exists in original configuration: Use Superstream's optimized value
44+
- If explicit linger exists: Use the maximum of original value and Superstream's optimized value
45+
46+
## Installation
47+
48+
### Maven
49+
50+
```xml
51+
<dependency>
52+
<groupId>ai.superstream</groupId>
53+
<artifactId>superstream-clients</artifactId>
54+
<version>1.0.0</version>
55+
</dependency>
2956
```
3057

31-
#### Akka Kafka Example
58+
### Gradle
3259

33-
```bash
34-
cd examples/akka-kafka-example
35-
mvn clean package
36-
export SUPERSTREAM_TOPICS_LIST=example-topic
37-
java -javaagent:../../target/superstream-clients-1.0.0.jar -jar target/akka-kafka-example-1.0.0-jar-with-dependencies.jar
60+
```groovy
61+
implementation 'ai.superstream:superstream-clients:1.0.0'
3862
```
3963

40-
## Building the Clients Library
64+
## Usage
4165

42-
### Command Line
66+
Add the Java agent to your application's startup command:
4367

4468
```bash
45-
mvn clean package -pl superstream-clients
69+
java -javaagent:/path/to/superstream-clients-1.0.0.jar -jar your-application.jar
4670
```
4771

48-
### IntelliJ IDEA
72+
### Docker Integration
4973

50-
1. Go to View → Tool Windows → Maven
51-
2. Expand `superstream-clients` → Lifecycle
52-
3. Double-click on `install`
74+
When using Superstream Clients with containerized applications, include the agent in your Dockerfile:
5375

54-
## Deployment
76+
```dockerfile
77+
FROM openjdk:11-jre
5578

56-
### Publishing to Maven Central
79+
# Copy your application
80+
COPY target/your-application.jar /app/your-application.jar
5781

58-
1. Configure Maven settings:
82+
# Copy the Superstream agent
83+
COPY path/to/superstream-clients-1.0.0.jar /app/lib/superstream-clients-1.0.0.jar
5984

60-
```xml
61-
<settings>
62-
<servers>
63-
<server>
64-
<id>ossrh</id>
65-
<username>your-sonatype-username</username>
66-
<password>your-sonatype-password</password>
67-
</server>
68-
</servers>
69-
</settings>
85+
# Set environment variables
86+
ENV SUPERSTREAM_TOPICS_LIST=your-topics
87+
88+
# Run with the Java agent
89+
ENTRYPOINT ["java", "-javaagent:/app/lib/superstream-clients-1.0.0.jar", "-jar", "/app/your-application.jar"]
7090
```
7191

72-
2. Deploy:
92+
Alternatively, you can use a multi-stage build to download the agent from Maven Central:
7393

74-
```bash
75-
cd superstream-clients
76-
mvn clean deploy -P release
94+
```dockerfile
95+
# Build stage
96+
FROM maven:3.8-openjdk-11 AS build
97+
98+
# Get the Superstream agent
99+
RUN mvn org.apache.maven.plugins:maven-dependency-plugin:3.2.0:get \
100+
-DgroupId=ai.superstream \
101+
-DartifactId=superstream-clients \
102+
-Dversion=1.0.0
103+
104+
RUN mvn org.apache.maven.plugins:maven-dependency-plugin:3.2.0:copy \
105+
-Dartifact=ai.superstream:superstream-clients:1.0.0 \
106+
-DoutputDirectory=/tmp
107+
108+
# Final stage
109+
FROM openjdk:11-jre
110+
111+
# Copy your application
112+
COPY target/your-application.jar /app/your-application.jar
113+
114+
# Copy the agent from the build stage
115+
COPY --from=build /tmp/superstream-clients-1.0.0.jar /app/lib/superstream-clients-1.0.0.jar
77116
```
78117

79-
### Publishing to Artifactory
118+
### Required Environment Variables
119+
120+
- `SUPERSTREAM_TOPICS_LIST`: Comma-separated list of topics your application produces to
80121

81-
To deploy to your organization's Artifactory:
122+
### Optional Environment Variables
82123

124+
- `SUPERSTREAM_LATENCY_SENSITIVE`: Set to "true" to prevent any modification to linger.ms values
125+
- `SUPERSTREAM_DISABLED`: Set to "true" to disable optimization
126+
127+
Example:
83128
```bash
84-
cd superstream-clients
85-
mvn clean deploy
129+
export SUPERSTREAM_TOPICS_LIST=orders,payments,user-events
130+
export SUPERSTREAM_LATENCY_SENSITIVE=true
86131
```
87132

133+
## Prerequisites
134+
135+
- Java 11 or higher
136+
- Kafka cluster that is connected to the Superstream's console
137+
- Read and write permissions to the `superstream.*` topics
138+
88139
## License
89140

90-
Apache License 2.0
141+
This project is licensed under the Apache License 2.0.

0 commit comments

Comments
 (0)