承接 xlabs/rabbitmqbundle 相关项目开发

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

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

xlabs/rabbitmqbundle

Composer 安装命令:

composer require xlabs/rabbitmqbundle

包简介

RabbitMQ wrapper bundle

README 文档

README

A Symfony2 RabbitMQ wrapper.

Installation

Install through composer:

php -d memory_limit=-1 composer.phar require xlabs/rabbitmqbundle

In your AppKernel

public function registerbundles()
{
    return [
    	...
    	...
    	new XLabs\RabbitMQBundle\XLabsRabbitMQBundle(),
    ];
}

Configuration sample

Default values are shown below:

# app/config/config.yml
  
x_labs_rabbit_mq:
    host: 192.168.5.26
    port: 5672
    vhost: '/'
    user: admin
    password: admin
    exchange: gamification_exchange
    api_port: 15672
    queue_prefix: gamification_

Usage

First define your custom producer and its consumer:

# YourBundle/Resources/config/services.yml
    ...
    my_custom_producer:
        class: YourBundle\YourFolder\Producer
        parent: xlabs_rmq_producer
        shared: false
    my_custom_consumer:
        class: YourBundle\YourFolder\Consumer
        tags:
            - { name: console.command }

Your Producer class:

# YourBundle\YourFolder\Producer.php
  
namespace YourBundle\YourFolder;
  
use XLabs\RabbitMQBundle\RabbitMQ\Producer as Parent_Producer;
  
class Producer extends Parent_Producer
{
    public static function getQueueName()
    {
        // set your custom queue name for this producer here
        return 'my_custom_queue_name';
    }
  
    // if you need to modify the data sent in the message, create the following function
    public function _process($data)
    {
        // here you can deal with the data in the message if needed before being consumed
    }
}

Your Consumer class:

# YourBundle\YourFolder\Consumer.php
  
namespace YourBundle\YourFolder;
  
use XLabs\RabbitMQBundle\RabbitMQ\Consumer as Parent_Consumer;
  
class Consumer extends Parent_Consumer
{
    // set your custom consumer command name
    protected static $consumer = 'my_custom_name:bla_bla_bla';
    
    // set a TTL > 0 to automatically close the consumer after period
    // set TTL = 0 or dont set it to not close the consumer
    protected $ttl = 0; // seconds
  
    // following function is required as it is
    protected function configure()
    {
        $this
            ->setName(self::$consumer)
        ;
    }
  
    // following function is required as it is
    public function getQueueName()
    {
        return Producer::getQueueName();
    }
  
    public function callback($msg)
    {
        // this is all sample code to output something on screen 
        $container = $this->getApplication()->getKernel()->getContainer();
  
        $msg = json_decode($msg->body);
  
        echo "\n".$this->getQueueName()." - ".date('H:i:s d-m-Y')."\n";
        echo "--------------------------------------------\n";
        foreach($msg as $i => $tracker_item)
        {
            echo $i." : ".$tracker_item."\n";
        }
    }
}

At this point you can already call your producer:

$container->get('my_custom_producer')->process(array(
    'key1' => 'value1',
    'key2' => 'value2',
    'key3' => 'value3'
));

And running the consumer:

php app/console my_custom_name:bla_bla_bla

Requirements

Make sure to add "management" tag to the rabbitmq user in order to use the API.

sudo rabbitmqctl set_user_tags USERNAME management

xlabs/rabbitmqbundle 适用场景与选型建议

xlabs/rabbitmqbundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2017 年 12 月 15 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 xlabs/rabbitmqbundle 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-12-15