Skip to content

Commit d102d49

Browse files
committed
implemented healthcheck and producer /consumer retries
1 parent 9ffa410 commit d102d49

23 files changed

Lines changed: 1514 additions & 318 deletions

IMPLEMENTATION_PLAN.md

Lines changed: 0 additions & 282 deletions
This file was deleted.

danube-client/pom.xml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@
4545
<artifactId>junit-jupiter</artifactId>
4646
<scope>test</scope>
4747
</dependency>
48+
<dependency>
49+
<groupId>org.slf4j</groupId>
50+
<artifactId>slf4j-simple</artifactId>
51+
<version>${slf4j.version}</version>
52+
<scope>test</scope>
53+
</dependency>
4854
</dependencies>
4955

5056
<build>
@@ -55,4 +61,30 @@
5561
</plugin>
5662
</plugins>
5763
</build>
64+
65+
<profiles>
66+
<profile>
67+
<id>integration-tests</id>
68+
<build>
69+
<plugins>
70+
<plugin>
71+
<groupId>org.apache.maven.plugins</groupId>
72+
<artifactId>maven-failsafe-plugin</artifactId>
73+
<version>${maven.surefire.plugin.version}</version>
74+
<configuration>
75+
<useModulePath>false</useModulePath>
76+
</configuration>
77+
<executions>
78+
<execution>
79+
<goals>
80+
<goal>integration-test</goal>
81+
<goal>verify</goal>
82+
</goals>
83+
</execution>
84+
</executions>
85+
</plugin>
86+
</plugins>
87+
</build>
88+
</profile>
89+
</profiles>
5890
</project>

danube-client/src/main/java/com/danubemessaging/client/Consumer.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.danubemessaging.client.errors.DanubeClientException;
44
import com.danubemessaging.client.internal.consumer.TopicConsumer;
5+
import com.danubemessaging.client.internal.retry.RetryManager;
56
import com.danubemessaging.client.model.StreamMessage;
67
import java.util.ArrayList;
78
import java.util.List;
@@ -59,6 +60,10 @@ public synchronized void subscribe() {
5960
List<String> partitions = client.lookupService().topicPartitions(client.serviceUri(), options.topic());
6061
List<String> targets = partitions.isEmpty() ? List.of(options.topic()) : partitions;
6162

63+
RetryManager retryManager = hasCustomRetryOptions()
64+
? new RetryManager(options.maxRetries(), options.baseBackoffMs(), options.maxBackoffMs())
65+
: client.retryManager();
66+
6267
List<TopicConsumer> createdConsumers = new ArrayList<>(targets.size());
6368
try {
6469
for (int i = 0; i < targets.size(); i++) {
@@ -73,7 +78,7 @@ public synchronized void subscribe() {
7378
client.lookupService(),
7479
client.authService(),
7580
client.healthCheckService(),
76-
client.retryManager(),
81+
retryManager,
7782
options,
7883
partitionTopic,
7984
partitionConsumerName);
@@ -194,6 +199,10 @@ private void notifyFatalReceiveError(TopicConsumer topicConsumer, RuntimeExcepti
194199
}
195200
}
196201

202+
private boolean hasCustomRetryOptions() {
203+
return options.maxRetries() > 0 || options.baseBackoffMs() > 0 || options.maxBackoffMs() > 0;
204+
}
205+
197206
private void ensureOpen() {
198207
if (lifecycleState.get() == LifecycleState.CLOSED) {
199208
throw new DanubeClientException("Consumer is closed");

0 commit comments

Comments
 (0)