autobus-php/autobus-bus-bundle

AutobusBusBundle

安装: 194

依赖: 1

建议者: 0

安全性: 0

星标: 1

关注者: 4

分支: 4

开放问题: 0

类型:symfony-bundle

2.3.11 2024-02-06 14:56 UTC

README

PHP可扩展服务总线

配置原子性工作,以便由cron、队列监听器或web服务执行。

要求

  • PHP 8+

安装

下载Bundle

composer require autobus-php/autobus-bus-bundle

下载所需的队列Bundle

composer require enqueue/gps:0.10.*
composer require enqueue/sqs:0.10.*

环境变量

更新您的 .env 文件以添加

# 'gps:' for Google PubSub / 'sqs:' for AWS SQS 
ENQUEUE_DSN=sqs:

# Only for AWS SQS usage
AWS_REGION=
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=

配置

主题作业

有2个队列系统可用

  • 使用 Google PubSub

使用 Supervisor 工具执行以下命令

php bin/console autobus:pubsub:consume
  • 使用 AWS SQS

    将以下行添加到您的crontab中

*/5 * * * * php bin/console autobus:sqs:consume

定时任务

将以下行添加到您的crontab中

* * * * * php bin/console autobus:cron:run

使用方法

创建作业

要创建一个新的作业

  • 创建它的类,实现 Autobus\Bundle\BusBundle\Runner\RunnerInterface 接口;它可以扩展 Autobus\Bundle\BusBundle\Runner\AbstractRunner
  • 在您的bundle的 services.yml 中将其声明为一个服务,带有标签 bus.runner
  • 从web UI创建实例