Reputation: 334
The selected answer for this question has some relevant information
I have a subscription with the following configuration:
and the following code:
const subscription = this.pubSubClient
.topic(this.topicName)
.subscription(this.subscriptionName)
subscription.on('message', (message: Message) => {
this.logger.verbose('Received message:', message.data.toString())
})
subscription.on('error', error => {
this.logger.error('Received error:', error)
})
Messages published to the corresponding topic are logged from the code above as expected, however, they are not being resent, even though I'm not acknowledging them within the configured Acknowledgement deadline (or at all).
The Metrics Explorer correctly shows the unacknowledged messages:
Furthermore, when I explicitly call .nack()
on the messages, they are resent, as expected.
Am I misunderstanding something?
Upvotes: 0
Views: 1012
Reputation: 150
For the nodejs-pubsub library, maxExtensionMinutes
is the maximum duration to extend the message deadline before redelivering. There is a closed issue regarding this parameter, just in case you find it useful.
You can use the modifyAckDeadline
parameter to extend the acknowledgement deadline (Dealing with duplicates and forcing retries).
From the PubSub side, PubSub guarantees At-Least-Once delivery, there are two exceptions that you might find useful (from documentation):
Upvotes: 0
Reputation: 334
I believe that the client library that I'm using, @google-cloud/pubsub
, automatically extends the acknowledgement deadline. With the following changes, I'm able to override that behavior, and the messages are indeed resent after the original acknowledgement deadline:
const flowControl: FlowControlOptions = {
maxExtensionMinutes: 0,
}
const subscription = this.pubSubClient
.topic(this.topicName)
.subscription(this.subscriptionName, { flowControl: flowControl })
subscription.on('message', (message: Message) => {
this.logger.verbose('Received message:', message.data.toString())
})
subscription.on('error', error => {
this.logger.error('Received error:', error)
})
Upvotes: 2