RobertIndie commented on code in PR #1410:
URL: https://github.com/apache/pulsar-client-go/pull/1410#discussion_r2378848279


##########
pulsar/consumer_impl.go:
##########
@@ -121,6 +121,10 @@ func newConsumer(client *client, options ConsumerOptions) 
(Consumer, error) {
                options.NackBackoffPolicy = new(defaultNackBackoffPolicy)
        }
 
+       if options.NackPrecisionBit <= 0 {
+               options.NackPrecisionBit = 8
+       }

Review Comment:
   According to the java doc, the `0` should be a valid value:
   
   > If the value is 0, the redelivery time will be accurate to ms.
   
   If this config is a optional config, we could use a pointer type.



##########
pulsar/consumer_test.go:
##########
@@ -1216,13 +1217,86 @@ func TestConsumerNack(t *testing.T) {
        // Failed messages should be resent
 
        // We should only receive the odd messages
-       for i := 1; i < N; i += 2 {
+       receivedOdd := 0
+       expectedOdd := (N + 1) / 2 // Expected number of odd message IDs
+
+       for receivedOdd < expectedOdd {
                msg, err := consumer.Receive(ctx)
                assert.Nil(t, err)
-               assert.Equal(t, fmt.Sprintf("msg-content-%d", i), 
string(msg.Payload()))
 
+               // Extract message ID from the payload (e.g., "msg-content-15")
+               var id int
+               _, err = fmt.Sscanf(string(msg.Payload()), "msg-content-%d", 
&id)
+               assert.Nil(t, err)
+
+               // Count only odd message IDs
+               if id%2 == 1 {
+                       assert.True(t, id%2 == 1) // Optional check, included 
for clarity
+                       receivedOdd++
+               }
+
+               // Acknowledge message to mark it as processed
                consumer.Ack(msg)
        }
+
+       // Verify that the correct number of odd messages were received
+       assert.Equal(t, expectedOdd, receivedOdd)

Review Comment:
   The consumer consumption should be strictly ordering. Otherwise, it would 
break many use cases.



-- 
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