cog/stupidmqbundle
最新稳定版本:2.4.7
Composer 安装命令:
composer require cog/stupidmqbundle
包简介
stupid message queue bundle for sf2
关键字:
README 文档
README
Bundle to support stupidMessageQueue into Symfony application.
Installation
Add requirement into you composer.json :
"cog/stupidmqbundle":"2.4.*"
Then enable the bundle into app/AppKernel.php :
new CoG\StupidMQBundle\CoGStupidMQBundle()
Optionnaly, if you are using Doctrine Orm, you can use it to easily install message queue table :
php app/console doctrine:schema:update --force
This command will create for you a new table cog_stupidmq to store your messages.
Creating a message queue
Edit your services.xml to add your own queues :
<!-- Messages Queues -->
<service id="my.queue" class="%cog_stupidmq.queue.class%">
<argument type="service" id="cog_stupidmq.channel" />
<argument>my.queue</argument>
<tag name="cog_stupidmq.queue"/>
</service>
Adding message into the queue
$queue = $this->getContainer()->get('my.queue'); $queue->publish('This is a message !');
Adding a worker
To consume messages, you have to create a worker class like this :
<?php namespace My\Bundle\Worker; use CoG\StupidMQBundle\Worker\WorkerInterface; class MyWorker implements WorkerInterface { public function execute( $message ) { var_dump($message); /* you ca give a feedback using \CoG\StupidMQBundle\Feeback\Feedback */ return Feedback::create( MessageInterface::STATE_DONE, 'here is my feedback' ); /* or just return a boolean */ return true; } public function getSubscribedQueues() { return array( 'my.queue' ); } public function getName() { return 'my.worker'; } }
Then you should register your worker, edit your services.xml :
<!-- Message Worker -->
<service id="my.worker" class="My\Bundle\Worker\MyWorker">
<tag name="cog_stupidmq.worker"/>
</service>
Running command
StupidMQBundle is coming with useful command to process messages :
$ php app/console cog:stupidmq:watch -m1
These command will watch your queue until a message have to be processed, then it will run a subprocess in order to treat it.
Command help :
$ php app/console cog:stupidmq:watch --help
cog/stupidmqbundle 适用场景与选型建议
cog/stupidmqbundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 11.81k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2012 年 12 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「message queue」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 cog/stupidmqbundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 cog/stupidmqbundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 cog/stupidmqbundle 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
PHP AMQP Binding Library
A Laravel package to monitor queue jobs.
Message queue statistics for OroPlatform
Redis backed library for creating background jobs and processing them later.
Behat extention for RabbitMQ
Ozioma for PHP library helps to make API calls to Ozioma Cloud Messaging and Communications Platform for birthday contact and sms newsletter subscription.
统计信息
- 总下载量: 11.81k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 22
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2012-12-04