Google PubSub的未确认消息未被客户端拉取。

huangapple go评论85阅读模式
英文:

Google PubSub's unacked messaged not getting pulled by the client

问题

我有一个非常简单的Node.js应用程序,订阅了一个发布/订阅主题。我已经在云控制台上将确认截止时间设置为10秒。

const client = new PubSub()
const sub = client.subscription('my-topic-sub')

sub.on("message", (msg) => {
  console.log("msg received")
})

当我向主题发布消息时,它被Node应用程序接收并打印日志,但由于我没有确认消息,我期望它会被重新传送,并且日志会再次打印出来。

我尝试过调整设置,并通过代码直接将ackDeadline选项传递给订阅,但没有效果。有趣的是,如果我nack消息,它会立即被重新传送。

英文:

I have a very simple Node.js application that is subscribed to a pub/sub topic. I have set the ack deadline to 10seconds on the cloud console.

const client = new PubSub()
const sub = client.subscription('my-topic-sub')

sub.on("message", (msg) => {
  console.log("msg received")
})

When I publish a message to the topic it gets received by the node app and the log is printed but since I don't ack the message I expect it to be re-delivered and the log to print again.

I have tried fiddling with the settings and pass the ackDeadline option directly to the subscription through code but no effect. The interesting thing is that if I nack the message it gets redelivered instantly.

答案1

得分: 0

默认情况下,客户端库将未确认消息的确认截止时间延长一小时,以阻止消息的重新传递。有关更多信息,请参阅租赁管理文档。您可以通过更改最大确认延期期限来更改截止时间延长的时长:

const options = {
  flowControl: {
    maxExtensionMinutes: 1,
  }
};

const subscription = pubSubClient.subscription('my-topic-sub', options);
英文:

By default, the client library extends the ack deadline of an unacknowledged message for an hour, which would prevent the redelivery of the message. See the lease management documentation for more information. You can change the length of time for which the deadline is extended by changing the maximum acknowledgement extension period:

const options = {
  flowControl: {
    maxExtensionMinutes: 1,
  }
};

const subscription = pubSubClient.subscription('my-topic-sub', options);

huangapple
  • 本文由 发表于 2023年6月15日 03:19:54
  • 转载请务必保留本文链接:https://go.coder-hub.com/76476905.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定