Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using requestTimeout from config, not from backoff algorithm in ZeebeSourceTaskFetcher #224

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import io.zeebe.kafka.connect.util.ManagedClient.AlreadyClosedException;
import io.zeebe.kafka.connect.util.VersionInfo;
import io.zeebe.kafka.connect.util.ZeebeClientHelper;
import java.time.Duration;
import java.util.Collections;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -88,11 +87,9 @@ public List<SourceRecord> poll() {

private Stream<ActivatedJob> fetchJobs(final String jobType) {
final int amount = inflightRegistry.capacityForType(jobType);
final Duration requestTimeout = backoff.currentDuration();

try {
return managedClient
.withClient(c -> taskFetcher.fetchBatch(c, jobType, amount, requestTimeout))
.stream();
return managedClient.withClient(c -> taskFetcher.fetchBatch(c, jobType, amount)).stream();
} catch (final AlreadyClosedException e) {
LOGGER.warn(
"Expected to activate jobs for type {}, but failed to receive response", jobType, e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import io.camunda.zeebe.client.ZeebeClient;
import io.camunda.zeebe.client.api.response.ActivatedJob;
import io.zeebe.kafka.connect.util.ZeebeClientConfigDef;
import java.time.Duration;
import java.util.Collections;
import java.util.List;
Expand All @@ -35,6 +36,7 @@ class ZeebeSourceTaskFetcher {
private final List<String> jobVariables;
private final Duration jobTimeout;
private final String workerName;
private final Duration requestTimeout;

ZeebeSourceTaskFetcher(
final ZeebeSourceConnectorConfig config, final ZeebeSourceTopicExtractor topicExtractor) {
Expand All @@ -43,15 +45,12 @@ class ZeebeSourceTaskFetcher {
jobVariables = config.getList(ZeebeSourceConnectorConfig.JOB_VARIABLES_CONFIG);
jobTimeout = Duration.ofMillis(config.getLong(ZeebeSourceConnectorConfig.JOB_TIMEOUT_CONFIG));
workerName = config.getString(ZeebeSourceConnectorConfig.WORKER_NAME_CONFIG);
requestTimeout = Duration.ofMillis(config.getLong(ZeebeClientConfigDef.REQUEST_TIMEOUT_CONFIG));
}

List<ActivatedJob> fetchBatch(
final ZeebeClient client,
final String jobType,
final int amount,
final Duration requestTimeout) {
List<ActivatedJob> fetchBatch(final ZeebeClient client, final String jobType, final int amount) {
final Map<Boolean, List<ActivatedJob>> jobs =
activateJobs(client, jobType, amount, requestTimeout).stream()
activateJobs(client, jobType, amount).stream()
.collect(Collectors.partitioningBy(this::isJobValid));

final List<ActivatedJob> validJobs = jobs.get(true);
Expand All @@ -63,10 +62,7 @@ List<ActivatedJob> fetchBatch(
}

private List<ActivatedJob> activateJobs(
final ZeebeClient client,
final String jobType,
final int amount,
final Duration requestTimeout) {
final ZeebeClient client, final String jobType, final int amount) {
LOGGER.trace(
"Sending activate jobs command for maximal {} jobs of type {} with request timeout {}",
amount,
Expand Down