定制 abc/job-worker-bundle 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

abc/job-worker-bundle

Composer 安装命令:

composer require abc/job-worker-bundle

包简介

A Symfony to process jobs from AbcJobServerBundle

README 文档

README

Build Status

A symfony bundle to process jobs managed by AbcJobServerBundle using php-enqueue as transport layer.

Note: This project is still in experimental!

Demo

You can find a demo here.

Installation

composer require abc/job-worker-bundle

Configuration Reference

abc_job_worker:
    server_baseUrl: # Required (e.g. http://domain.tld/api/
    default_queue: default
    default_replyTo: reply

Getting Started

Prerequisites

  1. A Symfony application with AbcJobServerBundle installed
  2. Enqueue transport is configured matching the configuration of AbcJobServerBundle

Create a job processor

A job processor must implement the interface ProcessorInterface.

interface ProcessorInterface
{
    public function process(?string $input, Context $context);
}

Register a job processor

A job processor must be registered using the tag abc.job.processor. You must define the tag attribute jobName with it which defines the name of the job that must be processed with this processor.

App\Job\SayHelloProcessor:
    tags:
        - { name: 'abc.job.processor', jobName: 'say_hello'}

Configure job routes

A route must be configured for every job. A route consist of three parameters: name specifies the the name of the job, queue specifies the name of the queue the job is sent to, replyTo specifies the name of the queue where the reply of a job is sent to.

Routes are configured by a class that implements the interface RouteProviderInterface.

<?php

namespace App;

use Abc\Job\RouteProviderInterface;

class JobRoutes implements RouteProviderInterface
{
    public static function getRoutes()
    {
        return [
            [
                'name' => 'job_A',
                'queue' => 'queue_A',
                'replyTo' => 'reply_default',
            ],
            [
                'name' => 'job_B',
                'queue' => 'queue_B',
                'replyTo' => 'reply_default',
            ],
            [
                'name' => 'job_C',
                'queue' => 'queue_B',
                'replyTo' => 'reply_C',
            ],
        ];
    }
}

A route provider must be registered using the tag abc.job.route_provider.

App\JobRoutes:
    tags:
        - { name: 'abc.job.route_provider'}

Commands

Command abc:job:process

The command abc:job:process processes one or more specific jobs, that have to be specified by name. You can provide a single job name or an array of job names as argument.

bin/console abc:job:process --help

Command abc:queue:process

The command abc:queue:process processes jobs one or more queues. It will process all jobs that have been registered.

bin/console abc:queue:process --help

You can provide a single queue name or an array of queues as argument.

Command abc:routes:register

The command abc:routes:register registers routes defined by a route provider on the server. Existing routes are overwritten but not deleted.

bin/console abc:routes:register --help

Command abc:broker:setup

The command abc:broker:setup declares queues at the broker for all registered routes.

bin/console abc:broker:setup --help

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-09-25

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固