petitpress/gps-messenger-bundle
Composer 安装命令:
composer require petitpress/gps-messenger-bundle
包简介
Google Pub/Sub transport for Symfony Messenger
关键字:
README 文档
README
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.
Features
- Compatible with the latest
google/cloud-pubsub2.*. - Zero extra dependencies beyond core Symfony (e.g.
Symfony Messenger) and Pub/Sub libraries. - Flexible and extensive configuration, available via options or DSN (Data Source Name), including
deadLetterPolicy,enableMessageOrdering,ackDeadlineSeconds). - Automatic Pub/Sub Topic and Subscription creation, with the ability to disable it if needed.
- Message ordering support using the
OrderingKeyStamp. - Keep-alive support for long-running Messenger workers.
Support
| Version | Status | Symfony Versions |
|---|---|---|
| 3.x | Actively Supported | >= 5.4, <8.0 |
| 4.x | Actively Supported | >= 7.4 |
Installation
Step 1: Install the Bundle
From within container execute the following command to download the latest version of the bundle:
$ composer require petitpress/gps-messenger-bundle --no-scripts
Step 2: Configure environment variables
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 environment: GOOGLE_APPLICATION_CREDENTIALS='google-pubsub-credentials.json' GCLOUD_PROJECT='project-id' # use these for development environment (if you have installed Pub/Sub emulator): PUBSUB_EMULATOR_HOST=http://localhost:8538
or if you have credentials in a base64 encoded env variable:
# config/packages/messenger.yaml framework: messenger: transports: gps_transport: dsn: 'gps://default' options: client_config: credentials: '%env(json:base64:GOOGLE_PUBSUB_KEY)%'
Step 3: Configure Symfony Messenger
# config/packages/messenger.yaml framework: messenger: transports: gps_transport: dsn: 'gps://default' options: client_config: # optional (default: []) apiEndpoint: 'https://europe-west3-pubsub.googleapis.com' topic: # optional (default name: messages) name: 'messages' options: # optional create options if not exists (default: []), for all options take at look at https://cloud.google.com/php/docs/reference/cloud-pubsub/latest/Topic#_Google_Cloud_PubSub_Topic__create__ labels: - label1 - label2 subscription: # optional (default the same as topic.name) name: 'messages' options: # optional create options if not exists (default: []), for all options take a look at https://cloud.google.com/php/docs/reference/cloud-pubsub/latest/Subscription#_Google_Cloud_PubSub_Subscription__create__ enableExactlyOnceDelivery: true labels: - label1 - label2 pull: maxMessages: 10 # optional (default: 10)
or:
# config/packages/messenger.yaml framework: messenger: transports: gps_transport: dsn: 'gps://default/messages?client_config[apiEndpoint]=https://europe-west3-pubsub.googleapis.com&subscription[pull][maxMessages]=10'
to use emulator in local:
# config/packages/dev/messenger.yaml framework: messenger: transports: gps_transport: options: client_config: hasEmulator: true emulatorHost: '%env(PUBSUB_EMULATOR_HOST)%'
Step 4: Configure PetitPressGpsMessengerBundle (optional)
Configure the cache service where authentication tokens are stored. The default is cache.app.
# config/packages/petit_press_gps_messenger.yaml petit_press_gps_messenger: auth_cache: 'cache.app'
Step 5: Use available stamps if needed
-
OrderingKeyStamp: use for keeping messages of the same context in order. For more information, read an official documentation. -
AttributesStamp: use to add contextual metadata to serialized messages. For more information, read an official documentation. Can be very useful when used together with subscription filters. -
GpsSenderOptionsStamp: use to specify options for the second parameter of thepublishmethod in the Pub/Sub client.
Step 6: Create topics from config
bin/console messenger:setup-transports
License
This bundle is released under the MIT License.
petitpress/gps-messenger-bundle 适用场景与选型建议
petitpress/gps-messenger-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 559.56k 次下载、GitHub Stars 达 30, 最近一次更新时间为 2020 年 11 月 12 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「symfony」 「google」 「Messenger」 「pubsub」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 petitpress/gps-messenger-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 petitpress/gps-messenger-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 petitpress/gps-messenger-bundle 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
The bundle for easy using json-rpc api on your project
Enables the creation of cron-jobs tasks to be consumed by symfony/messenger
Messenger functionality for Laravel 5.2.
Bundle Symfony DaplosBundle
统计信息
- 总下载量: 559.56k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 30
- 点击次数: 35
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-11-12