@@ -36,8 +36,8 @@ import (
3636const defaultNackRedeliveryDelay = 1 * time .Minute
3737
3838type acker interface {
39- AckID (id trackingMessageID ) error
40- NackID (id trackingMessageID )
39+ AckID (id MessageID ) error
40+ NackID (id MessageID )
4141 NackMsg (msg Message )
4242}
4343
@@ -91,6 +91,15 @@ func newConsumer(client *client, options ConsumerOptions) (Consumer, error) {
9191 }
9292 }
9393
94+ if options .MaxPendingChunkedMessage == 0 {
95+ options .MaxPendingChunkedMessage = 100
96+ }
97+
98+ // the minimum timer interval is 100ms
99+ if options .ExpireTimeOfIncompleteChunk < 100 * time .Millisecond {
100+ options .ExpireTimeOfIncompleteChunk = time .Minute
101+ }
102+
94103 if options .NackBackoffPolicy == nil && options .EnableDefaultNackBackoffPolicy {
95104 options .NackBackoffPolicy = new (defaultNackBackoffPolicy )
96105 }
@@ -342,27 +351,30 @@ func (c *consumer) internalTopicSubscribeToPartitions() error {
342351 nackRedeliveryDelay = c .options .NackRedeliveryDelay
343352 }
344353 opts := & partitionConsumerOpts {
345- topic : pt ,
346- consumerName : c .consumerName ,
347- subscription : c .options .SubscriptionName ,
348- subscriptionType : c .options .Type ,
349- subscriptionInitPos : c .options .SubscriptionInitialPosition ,
350- partitionIdx : idx ,
351- receiverQueueSize : receiverQueueSize ,
352- nackRedeliveryDelay : nackRedeliveryDelay ,
353- nackBackoffPolicy : c .options .NackBackoffPolicy ,
354- metadata : metadata ,
355- subProperties : subProperties ,
356- replicateSubscriptionState : c .options .ReplicateSubscriptionState ,
357- startMessageID : trackingMessageID {},
358- subscriptionMode : durable ,
359- readCompacted : c .options .ReadCompacted ,
360- interceptors : c .options .Interceptors ,
361- maxReconnectToBroker : c .options .MaxReconnectToBroker ,
362- keySharedPolicy : c .options .KeySharedPolicy ,
363- schema : c .options .Schema ,
364- decryption : c .options .Decryption ,
365- ackWithResponse : c .options .AckWithResponse ,
354+ topic : pt ,
355+ consumerName : c .consumerName ,
356+ subscription : c .options .SubscriptionName ,
357+ subscriptionType : c .options .Type ,
358+ subscriptionInitPos : c .options .SubscriptionInitialPosition ,
359+ partitionIdx : idx ,
360+ receiverQueueSize : receiverQueueSize ,
361+ nackRedeliveryDelay : nackRedeliveryDelay ,
362+ nackBackoffPolicy : c .options .NackBackoffPolicy ,
363+ metadata : metadata ,
364+ subProperties : subProperties ,
365+ replicateSubscriptionState : c .options .ReplicateSubscriptionState ,
366+ startMessageID : trackingMessageID {},
367+ subscriptionMode : durable ,
368+ readCompacted : c .options .ReadCompacted ,
369+ interceptors : c .options .Interceptors ,
370+ maxReconnectToBroker : c .options .MaxReconnectToBroker ,
371+ keySharedPolicy : c .options .KeySharedPolicy ,
372+ schema : c .options .Schema ,
373+ decryption : c .options .Decryption ,
374+ ackWithResponse : c .options .AckWithResponse ,
375+ maxPendingChunkedMessage : c .options .MaxPendingChunkedMessage ,
376+ expireTimeOfIncompleteChunk : c .options .ExpireTimeOfIncompleteChunk ,
377+ autoAckIncompleteChunk : c .options .AutoAckIncompleteChunk ,
366378 }
367379 cons , err := newPartitionConsumer (c , c .client , opts , c .messageCh , c .dlq , c .metrics )
368380 ch <- ConsumerError {
@@ -453,16 +465,13 @@ func (c *consumer) Ack(msg Message) error {
453465
454466// AckID the consumption of a single message, identified by its MessageID
455467func (c * consumer ) AckID (msgID MessageID ) error {
456- mid , ok := c .messageID (msgID )
457- if ! ok {
458- return errors .New ("failed to convert trackingMessageID" )
459- }
460-
461- if mid .consumer != nil {
462- return mid .Ack ()
468+ if msgID .PartitionIdx () < 0 || int (msgID .PartitionIdx ()) >= len (c .consumers ) {
469+ c .log .Errorf ("invalid partition index %d expected a partition between [0-%d]" ,
470+ msgID .PartitionIdx (), len (c .consumers ))
471+ return errors .New ("invalid partition index" )
463472 }
464473
465- return c .consumers [mid . partitionIdx ].AckID (mid )
474+ return c .consumers [msgID . PartitionIdx () ].AckID (msgID )
466475}
467476
468477// ReconsumeLater mark a message for redelivery after custom delay
0 commit comments