crysalead/queue 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

crysalead/queue

Composer 安装命令:

composer require crysalead/queue

包简介

Simple queue consumer framework that supports message dispatching.

README 文档

README

Build Status

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

GitHub 信息

  • Stars: 1
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-10-23