Issue
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?
Solution
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)
})
Answered By - Jayz7522
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.