Path: redb-route/redb.Route.Kafka/KafkaComponent.cs Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/redb.Route.Kafka/KafkaComponent.cs ---- using redb.Route.Abstractions; using redb.Route.Core; using redb.Route.Extensions; namespace redb.Route.Kafka; /// /// Apache Kafka transport component for redb.Route. /// Scheme: kafka. /// /// URI format: kafka://topic-name?brokers=host:9092&groupId=group&autoOffsetReset=Earliest /// /// public sealed partial class KafkaComponent : ComponentBase { /// public override string Scheme => "kafka"; /// Structured XML form: <kafka topic="orders"/>. public override string? StructuredPathSynonym => "topic"; /// public override IEndpoint CreateEndpoint(EndpointUri uri) { ArgumentNullException.ThrowIfNull(uri); var options = new KafkaEndpointOptions(); options.BindFromUri(uri.RawParameters); // Resolve the named ConnectionFactory BEFORE Validate(): the factory may be the only // source of the brokers. A set-but-unknown name fails loud — a typo must never // silently fall back to URI parameters. KafkaConnectionFactory? factory = null; if (!string.IsNullOrEmpty(options.ConnectionFactory)) { factory = Context.GetRequiredFromRegistry(options.ConnectionFactory); if (string.IsNullOrWhiteSpace(options.Brokers)) options.Brokers = factory.Brokers; // Validate() and the consumer's groupId check see only the // options, so factory values that act as defaults must land there BEFORE validation - // otherwise "credentials via a named connectionFactory" (the error text's own advice) // and the factory's documented default GroupId can never work. URI still wins: // the copy happens only when the URI supplied nothing. if (string.IsNullOrWhiteSpace(options.SaslUsername)) options.SaslUsername = factory.SaslUsername; if (string.IsNullOrWhiteSpace(options.SaslPassword)) options.SaslPassword = factory.SaslPassword; if (string.IsNullOrWhiteSpace(options.GroupId)) options.GroupId = factory.GroupId; // The factory's additionalProperties are applied last too: the same properties are refused there. KafkaOptionParsers.RefuseReservedProperties(factory.AdditionalProperties, $"the additionalProperties of connection factory '{options.ConnectionFactory}'", options.IsIdempotentProducer); } options.Validate(); options.ResolveBatch(EndpointUri.Sanitize(uri.BaseKey)); return new KafkaEndpoint(uri, this, options, factory); } }