承接 mle86/wq-amqp 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

mle86/wq-amqp

Composer 安装命令:

composer require mle86/wq-amqp

包简介

An AMQP module for mle86/wq using the php-amqplib connector

README 文档

README

This package contains the PHP class mle86\WQ\WorkServerAdapter\AMQPWorkServer.

It supplements the mle86/wq package by implementing its WorkServerAdapter interface.

It connects to an AMQP server such as RabbitMQ using the php-amqplib/php-amqplib package.

It creates durable queues in the default exchange (“”) for immediate-delivery jobs and the durable “_phpwq._delayed” queue in the custom “_phpwq._delay_exchange” exchange for delayed jobs. Jobs stored with storeJob() are always durable as well. Empty queues or exchanges won't be deleted automatically.

Version and Compatibility

This is version 1.5.0 of mle86/wq-amqp.

It was developed for version 1.0.0 of mle86/wq and should be compatible with all of its future 1.x versions as well.

Installation and Dependencies

$ composer require mle86/wq-amqp

It requires PHP 8.0+.

It depends on mle86/wq and php-amqplib/php-amqplib, which in turn requires the mbstring, sockets, and bcmath PHP extensions.

Class reference

class mle86\WQ\WorkServerAdapter\AMQPWorkServer implements WorkServerAdapter

  • public function __construct (AMQPStreamConnection $connection, int $prefetchCount = 0)
    Constructor. Takes an already-configured AMQPStreamConnection instance to work with. Does not attempt to establish a connection itself – use the connect() factory method for that instead. $prefetchCount is the per-consumer prefetch limit (QoS): leave it at 0 (default) for the broker's default unlimited prefetch, or set it to a positive value (e.g. 1) to enable RabbitMQ “fair dispatch” so that several competing worker processes share a queue's backlog evenly instead of the first consumer(s) buffering everything.
  • public static function connect ($host = 'localhost', $port = 5672, $user = 'guest', $password = 'guest', $vhost = '/', $insist = false, $login_method = 'AMQPLAIN', $login_response = null, $locale = 'en_US', $connection_timeout = 3.0, $read_write_timeout = 3.0, $context = null, $keepalive = false, $heartbeat = 0, int $prefetchCount = 0)
    Factory method. See AMQPStreamConnection::__construct for the connection parameter descriptions; $prefetchCount is passed on to the constructor (see above).

Interface methods which are documented in the WorkServerAdapter interface:

  • public function storeJob (string $workQueue, Job $job, int $delay = 0)
  • public function getNextQueueEntry ($workQueue, int $timeout = DEFAULT_TIMEOUT): ?QueueEntry
  • public function buryEntry (QueueEntry $entry)
  • public function requeueEntry (QueueEntry $entry, int $delay, string $workQueue = null)
  • public function deleteEntry (QueueEntry $entry)

Usage example

<?php
use mle86\WQ\WorkServerAdapter\AMQPWorkServer;
use mle86\WQ\WorkProcessor;
use mle86\WQ\Job\Job;

$processor = new WorkProcessor( AMQPWorkServer::connect("localhost") );

while (true) {
    $processor->processNextJob("mail", function(Job $job) {
        $job->...;
    });
}

This executes all jobs available in the local AMQP server's “mail” queue, forever. It will however abort if one of the jobs throws an exception – you might want to add a logging try-catch block around the processNextJob() call as shown in WQ's “Quick Start” example.

mle86/wq-amqp 适用场景与选型建议

mle86/wq-amqp 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.57k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 04 月 22 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 mle86/wq-amqp 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 mle86/wq-amqp 我们能提供哪些服务?
定制开发 / 二次开发

基于 mle86/wq-amqp 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-04-22