如何在向 Google Cloud Pub/Sub 发布消息时找出未找到的资源?
How to find out which resource not found while publishing message to Google Cloud Pub/Sub?
我是 Google Cloud 的新手。我想从我的 nodejs 应用程序完成消息发布到 Google Cloud Pub/Sub 服务。但是,我在发布消息时收到以下错误消息:
Received error while publishing: Error: 5 NOT_FOUND: Resource not found (resource=193060).
我想不通resource=193060
。什么是 193060?
这是我的server.js:
const express = require('express');
const app = express();
const bodyParser = require("body-parser");
const {PubSub} = require('@google-cloud/pubsub');
// parse application/json
app.use(bodyParser.json({limit: '10mb'}))
// Creates a client; cache this for further use
const pubSubClient = new PubSub();
const topicName = 'projects/codeway-312008/topics/codeway-log';
const data2 = JSON.stringify({
type: 'event',
app_id: 'com.codeway.test',
session_id: 'vIfEMi9kJW',
event_name: 'about',
event_time: 1598196427881,
page: 'settings',
country: 'US',
region: 'New Jersey',
city: 'Newark',
user_id: '9t0lrnYLQr'
});
async function publishMessage() {
// Publishes the message as a string, e.g. "Hello, world!" or JSON.stringify(someObject)
const dataBuffer = Buffer.from(data2);
try {
const messageId = await pubSubClient.topic(topicName).publish(dataBuffer);
console.log(`Message ${messageId} published.`);
} catch (error) {
console.error(`Received error while publishing: ${error}`);
process.exitCode = 1;
}
}
publishMessage();
我的话题:
看起来缺少的资源是与主题关联的架构。它可能在创建主题后被删除。需要清理错误消息以使其更加清晰,因此 Cloud Pub/Sub 团队一定会这样做。
我是 Google Cloud 的新手。我想从我的 nodejs 应用程序完成消息发布到 Google Cloud Pub/Sub 服务。但是,我在发布消息时收到以下错误消息:
Received error while publishing: Error: 5 NOT_FOUND: Resource not found (resource=193060).
我想不通resource=193060
。什么是 193060?
这是我的server.js:
const express = require('express');
const app = express();
const bodyParser = require("body-parser");
const {PubSub} = require('@google-cloud/pubsub');
// parse application/json
app.use(bodyParser.json({limit: '10mb'}))
// Creates a client; cache this for further use
const pubSubClient = new PubSub();
const topicName = 'projects/codeway-312008/topics/codeway-log';
const data2 = JSON.stringify({
type: 'event',
app_id: 'com.codeway.test',
session_id: 'vIfEMi9kJW',
event_name: 'about',
event_time: 1598196427881,
page: 'settings',
country: 'US',
region: 'New Jersey',
city: 'Newark',
user_id: '9t0lrnYLQr'
});
async function publishMessage() {
// Publishes the message as a string, e.g. "Hello, world!" or JSON.stringify(someObject)
const dataBuffer = Buffer.from(data2);
try {
const messageId = await pubSubClient.topic(topicName).publish(dataBuffer);
console.log(`Message ${messageId} published.`);
} catch (error) {
console.error(`Received error while publishing: ${error}`);
process.exitCode = 1;
}
}
publishMessage();
我的话题:
看起来缺少的资源是与主题关联的架构。它可能在创建主题后被删除。需要清理错误消息以使其更加清晰,因此 Cloud Pub/Sub 团队一定会这样做。