使用workerman消费队列数据
You can add this library as a local, per-project dependency to your project using Composer:
composer require plumber/plumber
$queuename = "queuename";
$callback = "test::test"; //消费sqs数据会会交由该方法处理
$config = []; //配置信息
$plumber = new plumber($queuename, $callback, $config);
$plumber->run();
config配置信息说明
provider
- 队列产品, 如SQS, RabbitMQcount
- workerman所起的进程数量rabbitmq
- rabbitmq credentials 集合host
- 链接地址port
- 端口login
- 用户名password
- 密码vhost
- vhost地址默认为"/
"
key
- aws account idsecret
- aws account secretregion
- region
callback函数返回数据格式
["msg" => "success"]
注意: 只要当msg为successs
时, 程序才会从队列中移除已经处理的消息
Usage: php yourfile <command> [mode]
Commands:
start Start worker in DEBUG mode.
Use mode -d to start in DAEMON mode.
stop Stop worker.
Use mode -g to stop gracefully.
restart Restart workers.
Use mode -d to start in DAEMON mode.
Use mode -g to stop gracefully.
reload Reload codes.
Use mode -g to reload gracefully.
status Get worker status.
Use mode -d to show live status.
connections Get worker connections.