crysalead/queue
Composer 安装命令:
composer require crysalead/queue
包简介
Simple queue consumer framework that supports message dispatching.
README 文档
README
Install
composer require crysalead/queue
Basic usage
Create Queue instance
$broker = new Lead\Queue\Adapter\Sqs( "https://queue.url", new SqsClient([ 'version' => 'latest', 'region' => '<region>', 'credentials' => [ 'key'=> '<key>', 'secret'=>'<secretKey>' ] ]) );
Listen on queue
Listening is a blocking call and runs in an infinite loop (up to default 20s polling timout). Your callback will be triggered when a new Message has arrived.
$broker->listen(function($job) { if (!$job) { return; } /** * * Process the job... * */ // Delete the job from Queue. $job->delete(); });
Shutting down the Queue
You may shutdown the queue by using the shutdown() method.
The Queue instance will respond to PCNTL signals in a safe manner that will not interrupt in the middle of Message processing. You can install signal handlers in your code to cleanly and safely shutdown the service.
pcntl_signal( SIGINT, function() use ($broker) { $broker->shutdown(); } );
Acknowledgements
- Syndicate (this repo is a simple fork of his brillant work).
统计信息
- 总下载量: 8.57k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-10-23