This bundle provides a simple implementation of Google Pub/Sub transport for Symfony Messenger.
The bundle requires only symfony/messenger
, google/cloud-pubsub
and symfony/options-resolver
packages.
In contrast with Enqueue GPS transport,
it doesn't require Enqueue
and some bridge.
It supports ordering messages with OrderingKeyStamp
and it's not outdated.
From within container execute the following command to download the latest version of the bundle:
$ composer require petitpress/gps-messenger-bundle --no-scripts
Official Google Cloud PubSub SDK requires some globally accessible environment variables.
You might need to change default Symfony DotEnv instance to use putenv
as Google needs to access some variables through getenv
. To do so, use putenv method in config/bootstrap.php
:
(new Dotenv())->usePutenv()->...
List of Google Pub/Sub configurable variables :
# use these for production environemnt:
GOOGLE_APPLICATION_CREDENTIALS='google-pubsub-credentials.json'
GCLOUD_PROJECT='project-id'
# use these for development environemnt (if you have installed Pub/Sub emulator):
PUBSUB_EMULATOR_HOST=http://localhost:8538
# config/packages/messenger.yaml
framework:
messenger:
transports:
gps_transport:
dsn: 'gps://default'
options:
max_messages_pull: 10 # optional (default: 10)
topic: # optional (default name: messages)
name: 'messages'
queue: # optional (default the same as topic.name)
name: 'messages'
or:
# config/packages/messenger.yaml
framework:
messenger:
transports:
gps_transport:
dsn: 'gps://default/messages?max_messages_pull=10'
OrderingKeyStamp
: use for keeping messages of the same context in order. For more information, read an official documentation.