Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 如何使用Google PubSub(@Google cloud/PubSub)确认_Node.js_Publish Subscribe_Gcloud_Google Cloud Pubsub - Fatal编程技术网

Node.js 如何使用Google PubSub(@Google cloud/PubSub)确认

Node.js 如何使用Google PubSub(@Google cloud/PubSub)确认,node.js,publish-subscribe,gcloud,google-cloud-pubsub,Node.js,Publish Subscribe,Gcloud,Google Cloud Pubsub,使用此示例: 按照这个例子,消息(成功和失败)都没有被确认,谷歌甚至没有在页面上提到“确认”这个词。因此,它们被重试,无法扩展。没有文档的完整拦截器 使用以下命令时,如何在Google Pub Sub中确认消息: const Pubsub = require('@google-cloud/pubsub'); 我建议你看看这个。基本上,它与message.ack()一起出现在messageHandler中,我建议您看看这个。基本上,它与message.ack()一起出现在messageHandl

使用此示例:

按照这个例子,消息(成功和失败)都没有被确认,谷歌甚至没有在页面上提到“确认”这个词。因此,它们被重试,无法扩展。没有文档的完整拦截器

使用以下命令时,如何在Google Pub Sub中确认消息:

const Pubsub = require('@google-cloud/pubsub');

我建议你看看这个。基本上,它与
message.ack()
一起出现在
messageHandler

中,我建议您看看这个。基本上,它与
message.ack()
一起出现在
messageHandler

谷歌的展示中:

。。。它从不确认()。因此,google示例将始终重新运行所有任务

改为:

// Event handlers
function handleMessage(message) {
  try {
    cb(null, message);   
  } catch (err) {
    console.log('Failed to handle message with data: [' + message.data + '] - Removing.  Err: ' +  err.toString());
    message.ack();
  }
}
。。。这样做可以让处理函数在需要时确认()

。。。它从不确认()。因此,google示例将始终重新运行所有任务

改为:

// Event handlers
function handleMessage(message) {
  try {
    cb(null, message);   
  } catch (err) {
    console.log('Failed to handle message with data: [' + message.data + '] - Removing.  Err: ' +  err.toString());
    message.ack();
  }
}

。。。这样做可以使处理函数在需要时确认()。

谢谢。事实证明,这是谷歌文档中的一个遗漏。谢谢。事实证明,这是谷歌文档中的一个遗漏。