Skip to content

Commit b969bbf

Browse files
authored
Add receiverQueueSize to pulsar (#3589)
Signed-off-by: yaron2 <[email protected]>
1 parent 8f5b880 commit b969bbf

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

pubsub/pulsar/metadata.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ type pulsarMetadata struct {
3636
PrivateKey string `mapstructure:"privateKey"`
3737
Keys string `mapstructure:"keys"`
3838
MaxConcurrentHandlers uint `mapstructure:"maxConcurrentHandlers"`
39+
ReceiverQueueSize int `mapstructure:"receiverQueueSize"`
3940

4041
Token string `mapstructure:"token"`
4142
oauth2.ClientCredentialsMetadata `mapstructure:",squash"`

pubsub/pulsar/metadata.yaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,4 +176,11 @@ metadata:
176176
description: |
177177
Sets the maximum number of concurrent messages sent to the application. Default is 100.
178178
default: '"100"'
179-
example: '"100"'
179+
example: '"100"'
180+
- name: receiverQueueSize
181+
type: number
182+
description: |
183+
Sets the size of the consumer receive queue.
184+
Controls how many messages can be accumulated by the consumer before it is explicitly called to read messages by Dapr.
185+
default: '"1000"'
186+
example: '"1000"'

pubsub/pulsar/pulsar.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ const (
8080
defaultRedeliveryDelay = 30 * time.Second
8181
// defaultConcurrency controls the number of concurrent messages sent to the app.
8282
defaultConcurrency = 100
83+
// defaultReceiverQueueSize controls the number of messages the pulsar sdk pulls before dapr explicitly consumes the messages.
84+
defaultReceiverQueueSize = 1000
8385

8486
subscribeTypeKey = "subscribeType"
8587

@@ -125,6 +127,7 @@ func parsePulsarMetadata(meta pubsub.Metadata) (*pulsarMetadata, error) {
125127
BatchingMaxSize: defaultMaxBatchSize,
126128
RedeliveryDelay: defaultRedeliveryDelay,
127129
MaxConcurrentHandlers: defaultConcurrency,
130+
ReceiverQueueSize: defaultReceiverQueueSize,
128131
}
129132

130133
if err := kitmd.DecodeMetadata(meta.Properties, &m); err != nil {
@@ -403,6 +406,7 @@ func (p *Pulsar) Subscribe(ctx context.Context, req pubsub.SubscribeRequest, han
403406
Type: getSubscribeType(req.Metadata),
404407
MessageChannel: channel,
405408
NackRedeliveryDelay: p.metadata.RedeliveryDelay,
409+
ReceiverQueueSize: p.metadata.ReceiverQueueSize,
406410
}
407411

408412
if p.useConsumerEncryption() {

0 commit comments

Comments
 (0)