@@ -114,16 +114,20 @@ func (c *consumerBuilder) Build() (kafka.Consumer, error) {
114
114
func (c * consumerBuilder ) build () (* consumer.MultiClusterConsumer , error ) {
115
115
// build TopicList per cluster
116
116
for _ , consumerTopic := range c .kafkaConfig .TopicList {
117
- // first, add TopicConsumer for original topic.
117
+ // first, add TopicConsumer for original topic if topic is well defined .
118
118
// disabling offset commit only applies for the original topic.
119
- partitionConsumerFactory := consumer .NewPartitionConsumer
120
- if ! c .kafkaConfig .Offsets .Commits .Enabled {
121
- partitionConsumerFactory = consumer .NewPartitionConsumerWithoutCommit
119
+ if consumerTopic .Topic .Name != "" && consumerTopic .Topic .Cluster != "" {
120
+ partitionConsumerFactory := consumer .NewPartitionConsumer
121
+ if ! c .kafkaConfig .Offsets .Commits .Enabled {
122
+ partitionConsumerFactory = consumer .NewPartitionConsumerWithoutCommit
123
+ }
124
+ c .addTopicToClusterTopicsMap (consumer.Topic {ConsumerTopic : consumerTopic , DLQMetadataDecoder : consumer .NoopDLQMetadataDecoder , PartitionConsumerFactory : partitionConsumerFactory }, c .kafkaConfig .Offsets .Initial .Offset )
122
125
}
123
- c . addTopicToClusterTopicsMap (consumer. Topic { ConsumerTopic : consumerTopic , DLQMetadataDecoder : consumer . NoopDLQMetadataDecoder , PartitionConsumerFactory : partitionConsumerFactory }, c . kafkaConfig . Offsets . Initial . Offset )
126
+ // Second, add retryQ topic if enabled.
124
127
if consumerTopic .RetryQ .Name != "" && consumerTopic .RetryQ .Cluster != "" {
125
128
c .addTopicToClusterTopicsMap (consumer.Topic {ConsumerTopic : topicToRetryTopic (consumerTopic ), DLQMetadataDecoder : consumer .ProtobufDLQMetadataDecoder , PartitionConsumerFactory : consumer .NewPartitionConsumer }, sarama .OffsetOldest )
126
129
}
130
+ // Third, add DLQ topic if enabled.
127
131
if consumerTopic .DLQ .Name != "" && consumerTopic .DLQ .Cluster != "" {
128
132
c .addTopicToClusterTopicsMap (consumer.Topic {ConsumerTopic : topicToDLQTopic (consumerTopic ), DLQMetadataDecoder : consumer .ProtobufDLQMetadataDecoder , PartitionConsumerFactory : consumer .NewRangePartitionConsumer }, sarama .OffsetOldest )
129
133
}
0 commit comments