Skip to main content
Version: v2

PubSub Drivers

Google PubSub Driver#

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

The GCP project-id can be set via the env var and GOOGLE_CLOUD_PROJECT and service account via GOOGLE_APPLICATION_CREDENTIALS to function correctly. If not provided then the sdk will automatically try to get the values from home directory/service account.

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

note

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

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