jiromm/queue-manager 问题修复 & 功能扩展

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

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

jiromm/queue-manager

Composer 安装命令:

composer require jiromm/queue-manager

包简介

The Queue Manager

README 文档

README

<?php

require __DIR__ . "/../../vendor/autoload.php";

$loop = \React\EventLoop\Factory::create();
$killer = new \React\Signals\Killer\SerialKiller($loop, [SIGTERM, SIGINT]);
$adapter = new class($loop) implements \Jiromm\QueueManager\Interfaces\MessageQueueAdapterInterface {
    protected $manager;
    protected $loop;

    public function __construct(\React\EventLoop\LoopInterface $loop)
    {
        $this->loop = $loop;
    }

    public function send(string $queue, string $message): void
    {
        $job = new \Jiromm\QueueManager\Message\Job($message);
        echo $job->serialize() . ' SENT' . PHP_EOL;
    }

    public function receive(string $queue, callable $callback)
    {
        return $this->loop->addPeriodicTimer(1, function () use ($callback) {
            $job = new \Jiromm\QueueManager\Message\Job('Text from queue');

            echo 'working...' . PHP_EOL;
            shell_exec('exec sleep 10s');
            echo 'done' . PHP_EOL;

            $callback($job->serialize());
        });
    }

    public function getMessageCount(string $queue): int
    {
        mt_rand(1, 5);
    }
};

$killer->onExit(function ($signal) use ($loop) {
    echo sprintf('Termination signal [%d] received.', $signal) . PHP_EOL;
    $loop->stop();
});

$manager = new \Jiromm\QueueManager\QueueManager(
    $adapter,
    $loop,
    $killer
);

$job = new \Jiromm\QueueManager\Message\Job('Test string');
$manager->send('queue_name', $job);
$manager->receive('queue_name', function (\Jiromm\QueueManager\Message\JobInterface $job) {
    echo $job->getMessage() . PHP_EOL;
});

统计信息

  • 总下载量: 12
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-12-13

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固