sagacorp/yii2-queue-azure-service-bus
Composer 安装命令:
composer require sagacorp/yii2-queue-azure-service-bus
包简介
Yii2 Queue driver for Azure service bus
README 文档
README
This extension is a Yii2 Queue driver for queues based on Microsoft Azure Service Bus.
It uses the Azure Service Bus REST API
Installation
Install this extension with composer.
Either run
php composer.phar require --prefer-dist sagacorp/yii2-queue-azure-service-bus
or add the extension to your composer json.
"sagacorp/yii2-queue-azure-service-bus": "^5.0"
Basic Usage
First, you may configure your Azure service Bus.
Then, configure yii2 queue, and the service bus like the following:
return [ 'components' => [ 'queue' => [ 'class' => \saga\queue\azure\Queue::class, 'as log' => \yii\queue\LogBehavior, 'serializer' => \yii\queue\serializers\JsonSerializer::class, 'serviceBus' => [ 'class' => \saga\queue\azure\service\ServiceBus::class, // Where to connect. Either a connection string... 'connectionString' => 'Endpoint=sb://(namespace).servicebus.windows.net/;EntityPath=(queue)', // ...or the namespace and queue directly. 'namespace' => 'your service bus namespace', 'queue' => 'the name of your Azure Service Bus queue (can be different than the name used as config key)', // Required: how to authenticate (see below). When SharedAccessKeyName and SharedAccessKey are present in connectionString, a SasTokenProvider is configured automatically. 'tokenProvider' => [ 'class' => \saga\queue\azure\service\SasTokenProvider::class, 'sharedAccessKeyName' => 'your shared access key name', 'sharedAccessKey' => 'your shared access key', ], ], ], ], ];
Authentication
Authentication is handled by a dedicated tokenProvider component, so the ServiceBus component
itself only carries the connection parameters. It is required — unless a connection string with a
shared access key is supplied, in which case a SasTokenProvider is configured automatically. The
tokenProvider accepts a configuration array (as shown below), a shared application component id,
or an already built TokenProvider instance. Two providers are shipped:
SasTokenProvider — Shared Access Signature
authentication:
'tokenProvider' => [ 'class' => \saga\queue\azure\service\SasTokenProvider::class, 'sharedAccessKeyName' => '...', 'sharedAccessKey' => '...', ],
When the ServiceBus connectionString already contains SharedAccessKeyName and
SharedAccessKey, this provider is configured automatically and tokenProvider can be omitted.
AzureAdTokenProvider — Azure AD
authentication via azure-oss/identity's
DefaultAzureCredential (environment variables, then workload identity). The acquired access token
is used as a Bearer token against the Service Bus REST API. When the Azure Workload Identity
mutating webhook is enabled, the credentials are injected automatically through the AZURE_*
environment variables, so no configuration is needed:
'tokenProvider' => \saga\queue\azure\service\AzureAdTokenProvider::class,
Optionally tune the scope and token caching:
'tokenProvider' => [ 'class' => \saga\queue\azure\service\AzureAdTokenProvider::class, 'scope' => 'https://servicebus.azure.net/.default', // default // Shared token cache. Defaults to the application `cache` component when available, otherwise // the token is only kept in memory for the lifetime of the worker. Set to false to opt out, or // pass another cache component id / configuration / instance. 'cache' => 'cache', 'expiryLeeway' => 300, // seconds before expiry at which the cached token is refreshed ],
This provider requires a PSR-18 HTTP client and PSR-17 factories to be installed, for example
composer require guzzlehttp/guzzle.
The targeted identity must be granted a Service Bus data plane role (e.g. Azure Service Bus Data Sender / Data Receiver) on the namespace or queue.
Once configured, you can send a task into the queue:
Yii::$app->queue->push(new DownloadJob([ 'url' => 'http://example.com/image.jpg', 'file' => '/tmp/image.jpg', ]));
sagacorp/yii2-queue-azure-service-bus 适用场景与选型建议
sagacorp/yii2-queue-azure-service-bus 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 824 次下载、GitHub Stars 达 0, 最近一次更新时间为 2021 年 07 月 12 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「queue」 「service」 「azure」 「microsoft」 「yii」 「bus」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 sagacorp/yii2-queue-azure-service-bus 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 sagacorp/yii2-queue-azure-service-bus 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 sagacorp/yii2-queue-azure-service-bus 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Small library to access Microsoft Windows Azure Blob Storage with a Service or a StreamWrapper.
PHP AMQP Binding Library
A Laravel package to monitor queue jobs.
A fast and intuitive dependency injection container.
Adds Silverstripe Flysystem support for using the Azure Blob adapter
Registry service.
统计信息
- 总下载量: 824
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 14
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-07-12