Skip to main content
Version: v1

PubSub Drivers

Google PubSub Driver#

This is the default driver. It uses Google Cloud PubSub to send messages.

It requires the env vars GOOGLE_APPLICATION_CREDENTIALS and GOOGLE_CLOUD_PUB_SUB_PROJECT_ID to function correctly.

note

NOTE: Make sure the service account is assigned the correct roles

The role assigned to the service account in the credentials should be roles/pubsub.admin

This is required because we require the below permissions:

PermissionReason
pubsub.topics.publishPublish to Topic
pubsub.subscriptions.consumeConsume from Subscription
pubsub.topics.getGet Topic to create subscription for it
pubsub.topics.attachSubscriptionCreate subscription for a topic
pubsub.subscriptions.getGet subscription to start consuming it
pubsub.topics.createCreating Topics Automatically (for publishing, subscribing and DLQs)
pubsub.subscriptions.createCreating Subscriptions (for subscribing and DLQs)
resourcemanager.projects.getGet Project Number from Project to bind DLQ policies
pubsub.subscriptions.setIamPolicyAssigning Subscriber Role for DLQs
pubsub.topics.setIamPolicyAssigning Publisher Role for DLQs

Synchronous Driver#

If you would like to bypass Google PubSub and run your subscriptions synchronously (for development purposes) set the following environment variable:

PUBSUB_DRIVER=synchronous

This uses an EventEmitter based pubsub model, and hence only works inside a single process.

caution

NOTE: Not recommended for production use

This is useful for writing unit tests, read more in the testing guide

Features not supported in Synchronous Driver#

  • Filtering using attributes
  • Retrying failed messages