PubSub Drivers
#
Google PubSub DriverThis 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:
Permission | Reason |
---|---|
pubsub.topics.publish | Publish to Topic |
pubsub.subscriptions.consume | Consume from Subscription |
pubsub.topics.get | Get Topic to create subscription for it |
pubsub.topics.attachSubscription | Create subscription for a topic |
pubsub.subscriptions.get | Get subscription to start consuming it |
pubsub.topics.create | Creating Topics Automatically (for publishing, subscribing and DLQs) |
pubsub.subscriptions.create | Creating Subscriptions (for subscribing and DLQs) |
resourcemanager.projects.get | Get Project Number from Project to bind DLQ policies |
pubsub.subscriptions.setIamPolicy | Assigning Subscriber Role for DLQs |
pubsub.topics.setIamPolicy | Assigning Publisher Role for DLQs |
#
Synchronous DriverIf you would like to bypass Google PubSub and run your subscriptions synchronously (for development purposes) set the following environment variable:
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