Hi,
when i try to execute the following function I get: Error exec is not supported
exports = function(changeEvent) {
const topicName = 'topicname';
const data = JSON.stringify({foo: 'bar'});
//const {PubSub} = require('pubsub');
const {PubSub} = require('@google-cloud/pubsub')
// Creates a client; cache this for further use
const pubSubClient = new PubSub();
async function publishMessageWithCustomAttributes() {
// Publishes the message as a string, e.g. "Hello, world!" or JSON.stringify(someObject)
const dataBuffer = Buffer.from(data);
console.log(data);
// Add two custom attributes, origin and username, to the message
const customAttributes = {
origin: 'nodejs-sample',
username: 'gcp',
};
const messageId = await pubSubClient
.topic(topicName)
.publish(dataBuffer, customAttributes);
console.log(`Message ${messageId} published.`);
}
publishMessageWithCustomAttributes().catch(console.error);
};