Skip to content

Instantly share code, notes, and snippets.

@elephantsneverforget
Created August 11, 2023 19:27
Show Gist options
  • Save elephantsneverforget/36947e290791cefdd0ec8ef10a4873e1 to your computer and use it in GitHub Desktop.
Save elephantsneverforget/36947e290791cefdd0ec8ef10a4873e1 to your computer and use it in GitHub Desktop.
const {PubSub} = require('@google-cloud/pubsub');
async function listenForMessages() {
const pubsub = new PubSub();
const subscriptionName = 'elevar-event-subscription';
const subscription = pubsub.subscription(subscriptionName);
const messageHandler = (message) => {
// Handle event
message.ack();
};
subscription.on('message', messageHandler);
}
listenForMessages();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment