我试图在时间(大约50)发布多条消息但Pub / Sub给出的是截止日期超过/user_code/node_modules/@google-cloud/pubsub/node_modules/grpc/src/client.js:55错误.
const pubsub = PubSub();
const topic = pubsub.topic('send_wishes');
const publisher = topic.publisher();
//data is dictionary object
Object.keys(data).forEach(function(key){
var userObj = data[key];
const dataBuffer = Buffer.from(JSON.stringify(userObj));
const publisher = topic.publisher();
publisher.publish(dataBuffer)
.then((results) => {
const messageId = results[0];
console.log(`Message ${messageId} published.`);
return;
});
})
对于单个消息,它工作正常.对于批处理我尝试批量配置发布者但它也无法正常工作
const publisher = topic.publisher({
batching: {
maxMessages: 15,
maxMilliseconds: 2000
}
});
最佳答案 创建订阅后,请将确认截止日期的订阅时间更改为默认10秒至100秒.