Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-cloud-platform/3.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
Google cloud platform PubSub-Maximum交付尝试次数&;死板的话题_Google Cloud Platform_Google Cloud Pubsub - Fatal编程技术网

Google cloud platform PubSub-Maximum交付尝试次数&;死板的话题

Google cloud platform PubSub-Maximum交付尝试次数&;死板的话题,google-cloud-platform,google-cloud-pubsub,Google Cloud Platform,Google Cloud Pubsub,五一快乐 我正在做一个简单的POC来利用PusSub的死信主题特性。我将订阅配置为在最多20次传递尝试后将邮件重新发布到单独的死信主题(下面是订阅拉取代码和使用的示例邮件)。 注意:我使用云控制台配置了订阅 问题/挑战:即使尝试了36次传递,测试消息仍不会重新发布到死信主题。基于文档,我假设我的测试消息将被重新发布到死信主题,并且在尝试20次之后不应该被发送。我错过了什么? 拉取订阅代码 const{PubSub}=require('@googlecloud/PubSub'); var力矩=

五一快乐

我正在做一个简单的POC来利用PusSub的死信主题特性。我将订阅配置为在最多20次传递尝试后将邮件重新发布到单独的死信主题(下面是订阅拉取代码和使用的示例邮件)。 注意:我使用云控制台配置了订阅

问题/挑战:即使尝试了36次传递,测试消息仍不会重新发布到死信主题。基于文档,我假设我的测试消息将被重新发布到死信主题,并且在尝试20次之后不应该被发送。我错过了什么?

拉取订阅代码

const{PubSub}=require('@googlecloud/PubSub');
var力矩=要求的(‘力矩’);
process.env['GOOGLE_APPLICATION_CREDENTIALS']='abcxyz.json';
const pubSubClient=new PubSub();
常数超时=100;
异步函数listenWithCustomAttributes(){
const subscription=publisubclient.subscription(“projects/random-1234/subscriptions/testsub”);
//创建一个事件处理程序来处理消息
const messageHandler=(message)=>{
const datetime=moment().format('mmmm-do-yyyy,h:mm:ss-a');
log(`${datetime}:::${message.id}:`);
log(`${message.data}`);
log(`Delivery-trument:${message.deliverytrument}`);
log(`customattributes:${JSON.stringify(message.Attributes)}`);
console.log('\n');
//用于再交付的NACK
message.nack();
};
subscription.on('message',messageHandler);
设置超时(()=>{
subscription.removeListener('message',messageHandler);
},超时*1000000);
}

listenWithCustomAttributes()我终于能够解决这个问题了

根据“如果您使用云控制台配置了订阅,则会自动授予角色。”但是,这似乎不再有效。我们需要在订阅控制台的“死信”(除概述外)中授予所需的发布者和订阅者角色,或按照文档中的说明添加iam策略。