Copilot commented on code in PR #1456:
URL: https://github.com/apache/pulsar-client-go/pull/1456#discussion_r2691736738


##########
pulsar/consumer_regex.go:
##########
@@ -454,6 +481,11 @@ func (c *regexConsumer) topics() ([]string, error) {
        }
 
        filtered := filterTopics(topics, c.pattern)
+
+       if c.options.RetryEnable && c.options.DLQ != nil {
+               filtered = append(filtered, c.options.DLQ.RetryLetterTopic)

Review Comment:
   Appending the retry letter topic to the filtered topics list may cause 
issues during auto-discovery. The `topics()` method is called periodically by 
the monitor goroutine to discover new topics matching the pattern. If the RLQ 
topic doesn't match the regex pattern, repeatedly appending it could lead to 
duplicate subscription attempts or incorrect behavior. Consider checking if the 
RLQ topic is already in the filtered list before appending, or ensure the RLQ 
topic is subscribed to separately during consumer initialization rather than 
through the discovery mechanism.
   ```suggestion
                retryTopic := c.options.DLQ.RetryLetterTopic
                alreadyPresent := false
                for _, t := range filtered {
                        if t == retryTopic {
                                alreadyPresent = true
                                break
                        }
                }
                if !alreadyPresent {
                        filtered = append(filtered, retryTopic)
                }
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to