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

Set default Kafka auto offset explicitly if it is not defined (#1992) #1993

Merged
merged 1 commit into from
Oct 5, 2023
Merged
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 @@ -26,6 +26,7 @@
import org.apache.streampipes.messaging.kafka.security.KafkaSecurityUnauthenticatedPlainConfig;
import org.apache.streampipes.messaging.kafka.security.KafkaSecurityUnauthenticatedSSLConfig;
import org.apache.streampipes.model.staticproperty.StaticPropertyAlternative;
import org.apache.streampipes.model.staticproperty.StaticPropertyAlternatives;
import org.apache.streampipes.sdk.StaticProperties;
import org.apache.streampipes.sdk.helpers.Alternatives;
import org.apache.streampipes.sdk.helpers.Label;
Expand Down Expand Up @@ -123,12 +124,20 @@ public static KafkaConfig getConfig(IStaticPropertyExtractor extractor, boolean
new KafkaSecurityUnauthenticatedPlainConfig();
}

StaticPropertyAlternatives alternatives = extractor.getStaticPropertyByName(AUTO_OFFSET_RESET_CONFIG,
StaticPropertyAlternatives.class);

// Set default value if no value is provided.
if (alternatives == null) {
AutoOffsetResetConfig autoOffsetResetConfig = new AutoOffsetResetConfig(KafkaConnectUtils.LATEST);

String auto = extractor.selectedAlternativeInternalId(AUTO_OFFSET_RESET_CONFIG);
AutoOffsetResetConfig autoOffsetResetConfig = new AutoOffsetResetConfig(auto);
return new KafkaConfig(brokerUrl, port, topic, securityConfig, autoOffsetResetConfig);
} else {
String auto = extractor.selectedAlternativeInternalId(AUTO_OFFSET_RESET_CONFIG);
AutoOffsetResetConfig autoOffsetResetConfig = new AutoOffsetResetConfig(auto);

return new KafkaConfig(brokerUrl, port, topic, securityConfig, autoOffsetResetConfig);
return new KafkaConfig(brokerUrl, port, topic, securityConfig, autoOffsetResetConfig);
}
}

private static boolean isUseSSL(String authentication) {
Expand Down
Loading