rezzza/command-bus-bundle
Composer 安装命令:
composer require rezzza/command-bus-bundle
包简介
rezzza/command-bus integration to Symfony
README 文档
README
Integration of the CommandBus library into Symfony2.
Installation
Require rezzza/command-bus-bundle
to your composer.json file:
{
"require": {
"rezzza/command-bus-bundle": "~2.0"
}
}
Register the bundle in app/AppKernel.php:
// app/AppKernel.php public function registerBundles() { return array( // ... new Rezzza\CommandBusBundle\RezzzaCommandBusBundle() ); }
Update your config.yml:
framework: serializer: enabled: true
Usage
$bus = $container->get('rezzza_command_bus.command_bus.synchronous'); // synchronous is the name you given to your bus in configuration. $bus->handle(new FooCommand());
Bus
Direct, SncRedis & OldSoundRabbit are currently supported.
Commands
Commands must inherit from Rezzza\CommandBus\Domain\CommandInterface.
Register a command handler:
<service id="...." class="...."> <tag name="rezzza_command_bus.command_handler" command="FQCN\MyFirstActionCommand" /> <!-- when handle this command, method `myFirstAction` will be handled. --> <tag name="rezzza_command_bus.command_handler" command="FQCN\MySecondActionCommand" method="myMethod" /> </service>
Events
Events:
- on_consumer_response
- pre_handle_command
Register a listener:
<service id="service_id" class="Foo"> <tag name="rezzza_command_bus.event_listener" event="pre_handle_command" method="onPreHandleCommand" /> <tag name="rezzza_command_bus.event_listener" event="on_consumer_response" method="onConsumerResponse" /> </service>
Fail Strategy
See command-bus documentation.
Console Command
A Symfony console command is provided in this bundle
$ app/console rezzza:command_bus:consume "CommandToConsume"
Options available:
--consumer Which consumer should we use ? (default: "default")
--iteration-limit (-i) Limit of iterations, -1 for infinite.. (default: -1)
--time-limit During how many time this command will listen to the queue. (default: 60)
--usleep Micro seconds (default: 100000)
--lock Only one command processing ?
To watch activity of your consumer, you should register a console handler for monolog
monolog: handlers: console: type: console verbosity_levels: VERBOSITY_NORMAL: NOTICE
Configuration
rezzza_command_bus: buses: synchronous: direct asynchronous: rabbitmq: #define producer_guesser which allow to determine rigth producer for each command #producer name and command class name must be indentical #example: #producer name : source_entry_update #command class name : SourceEntryUpdateCommand producer_guesser: rezzza_command_bus.old_sound_rabbit.producer_guesser consumer_bus: synchronous #consumer handle command with synchronous bus snc_redis: client: default # snc redis client. read_block_timeout: 1 # see blpop documentation consumers: default: bus: synchronous fail_strategy: retry_then_fail: # When the command fail, it uses this strategy. # you could use too requeue, none, service. attempts: 10 requeue_on_fail: true handlers: # Do you want to use handlers provided in this bundle ? retry: synchronous # If you used retry_then_fail strategy, this handler is linked to Retry commands. failed: synchronous # If you used retry_then_fail strategy, this handler is linked to Failed commands.
Usage with JMS Serializer
rezzza_command_bus: logger_normalizer: symfony_serializer services: symfony_serializer: class: "Symfony\Component\Serializer\Serializer"
rezzza/command-bus-bundle 适用场景与选型建议
rezzza/command-bus-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 37.25k 次下载、GitHub Stars 达 5, 最近一次更新时间为 2015 年 06 月 22 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「bundle」 「command」 「bus」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 rezzza/command-bus-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 rezzza/command-bus-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 rezzza/command-bus-bundle 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A Wrapper for exec and it's results
Symfony bundle to monitor and execute commands
Easy command bus
2lenet/EasyAdminPlusBundle
Shell command module for PHP.
The bundle for easy using json-rpc api on your project
统计信息
- 总下载量: 37.25k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 7
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-06-22