-
Notifications
You must be signed in to change notification settings - Fork 1
queue gcp HowTo
GitHub Action edited this page Apr 21, 2026
·
1 revision
This guide explains Pub/Sub specific behaviors.
In GCP Pub/Sub, you publish to a Topic, but you listen to a Subscription.
When using @quatrain/queue-gcp:
-
send(data, target)expectstargetto be the name of a Topic. -
listen(target, handler)expectstargetto be the name of a Subscription.
It is your responsibility to ensure that the Subscription you are listening to is bound to the Topic you are publishing to in your GCP Console or Terraform scripts.
import { Queue } from '@quatrain/queue'
async function run() {
const pubsub = Queue.getAdapter('pubsub')
// Send to TOPIC
await pubsub.send({ action: 'process' }, 'worker-tasks-topic')
// Listen to SUBSCRIPTION
await pubsub.listen('worker-tasks-subscription', async (data) => {
console.log(data)
return true // Acknowledges the message
})
}