Skip to content

BatchReceivePolicy.maxNumMessages not working #259

@Myron5787

Description

@Myron5787

Dear Author,

I am currently utilizing the BatchReceiveAsync method in my project, and I've encountered an issue where the number of messages received exceeds the limit set by BatchReceivePolicy.maxNumMessages. Despite configuring the BatchReceivePolicy to limit the number of messages per batch, the method occasionally returns more messages than specified.

await using var consumer =
    await pulsarClient.NewConsumer(Schema.STRING(Encoding.UTF8))
        .Topic(_topic)
        .SubscriptionName(_subscription)
        .SubscriptionType(SubscriptionType.Shared)
        .SubscriptionInitialPosition(SubscriptionInitialPosition.Latest)
        .AutoUpdatePartitions(true)
        .NegativeAckRedeliveryDelay(TimeSpan.FromMilliseconds(500))
        .BatchReceivePolicy(new BatchReceivePolicy(100, -1L, TimeSpan.FromSeconds(10)))
        .SubscribeAsync();

var messages = await consumer.BatchReceiveAsync(CancellationToken);
var len = messages.Count; // len = ReceiverQueueSize(default: 1000)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions