定制 eo/job-queue-bundle 二次开发

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

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

eo/job-queue-bundle

Composer 安装命令:

composer require eo/job-queue-bundle

包简介

Allows to schedule Symfony2 console commands as jobs.

关键字:

README 文档

README

Dependencies Status

Mongodb ODM implementation for JMSJobQueueBundle which allows to schedule Symfony2 console commands as jobs.

Prerequisites

This version of the bundle requires Symfony 2.1+

Installation

Step 1: Download EoJobQueueBundle using composer

Add EoJobQueueBundle in your composer.json:

{
    "require": {
        "eo/job-queue-bundle": "dev-master"
    }
}

Now tell composer to download the bundle by running the command:

$ php composer.phar update eo/job-queue-bundle

Composer will install the bundle to your project's vendor/eo directory.

Step 2: Enable the bundle

Enable the bundle in the kernel:

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Eo\JobQueueBundle\EoJobQueueBundle(),
    );
}

Step 3: Change console base application class

Have your app/console use EoJobQueueBundle's Application:

// use Symfony\Bundle\FrameworkBundle\Console\Application;
use Eo\JobQueueBundle\Console\Application;

Step 4 (Optional): Configure bundle

Now that you have properly installed and enabled EoJobQueueBundle, the next step is to configure the bundle to work with the specific needs of your application.

To change the default job class used by the bundle, add the following configuration to your config.yml file

# app/config/config.yml
eo_job_queue:
    job_class: JuliusJobBundle:Job

Setting Up supervisord

For this bundle to work, you have to make sure that one (and only one) instance of the console command eo-job-queue:run is running at all times. You can easily achieve this by using supervisord.

A sample supervisord config might look like this:

[program:eo_job_queue_runner]
command=php %kernel.root_dir%/console eo-job-queue:run --env=prod --verbose
process_name=%(program_name)s
numprocs=1
directory=/tmp
autostart=true
autorestart=true
startsecs=5
startretries=10
user=www-data
redirect_stderr=false
stdout_logfile=%capistrano.shared_dir%/eo_job_queue_runner.out.log
stdout_capture_maxbytes=1MB
stderr_logfile=%capistrano.shared_dir%/eo_job_queue_runner.error.log
stderr_capture_maxbytes=1MB

For testing, or development, you can of course also run the command manually, but it will auto-exit after 15 minutes by default (you can change this with the --max-runtime=seconds option).

Usage

Creating Jobs

Creating jobs is super simple, you just need to persist an instance of Job:

<?php

$job = new Job('my-symfony2:command', array('some-args', 'or', '--options="foo"'));
$dm->persist($job);
$dm->flush($job);

Adding Dependencies Between Jobs

If you want to have a job run after another job finishes, you can also achieve this quite easily:

<?php

$job = new Job('a');
$dependentJob = new Job('b');
$dependentJob->addJobDependency($job);
$dm->persist($job);
$dm->persist($dependentJob);
$dm->flush();

Adding Related Documents to Jobs

If you want to link a job to another document, for example to find the job more easily, the job provides a special many-to-any association:

<?php

$job = new Job('a');
$job->addRelatedDocument($anyDocument);
$dm->persist($job);
$dm->flush();

$dm->getRepository('EoJobQueueBundle:Job')->findJobForRelatedDocument('a', $anyDocument);

Schedule a Jobs

If you want to schedule a job :

<?php

$job = new Job('a');
$date = new DateTime();
$date->add(new DateInterval('PT30M'));
$job->setExecuteAfter($date);
$dm->persist($job);
$dm->flush();

License

This bundle is under the Apache2 license. See the complete license in the bundle:

Resources/meta/LICENSE

Reporting an issue or a feature request

Issues and feature requests related to this bundle are tracked in the Github issue tracker https://github.com/eymengunay/EoJobQueueBundle/issues

eo/job-queue-bundle 适用场景与选型建议

eo/job-queue-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 8.96k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2013 年 05 月 21 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「queue」 「job」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

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

围绕 eo/job-queue-bundle 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Apache2
  • 更新时间: 2013-05-21