facile-it/mongodb-messenger-transport
Composer 安装命令:
composer require facile-it/mongodb-messenger-transport
包简介
A Symfony Messenger transport on MongoDB, on top of facile-it/mongodb-bundle
README 文档
README
A Symfony Messenger transport on MongoDB, on top of facile-it/mongodb-bundle
Installation
- To install this package, use Composer:
composer require facile-it/mongodb-messenger-transport
This package register itself as a bundle inside Symfony; you have to have both it and the FacileMongoDbBundle enabled, if you hadn't it before.
To do it, you either:
- let Flex enable it automatically, if you're using it:
# config/bundles.php # ... Facile\MongoDbBundle\FacileMongoDbBundle::class => ['all' => true], + Facile\MongoDbMessenger\FacileMongoDbMessengerBundle::class => ['all' => true], ];
- Enable it yourself in your kernel:
<?php
class Kernel extends BaseKernel
{
public function registerBundles(): array
{
return [
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
# ...
new Facile\MongoDbBundle\FacileMongoDbBundle(),
+ new Facile\MongoDbMessenger\FacileMongoDbMessengerBundle(),
];
}
}
Configuration
- If you haven't already, configure the MongoDB connection following instructions for
facile-it/mongodb-bundle - Using the connection name from that configuration (i.e.
defaultin the Flex recipe), configure a new transport for the Messenger like this:
# config/packages/messenger.yaml framework: messenger: transports: new_transport: 'facile-it-mongodb://default'
Note: when using it for the first time, or when calling the messenger:setup-transports console command, this transport creates the collection with an index for optimal performances, since it's tailored to the properties that are used to retrieve the messages.
Suggestions
It's suggested to use this transport for failed messages, like the Doctrine one; if you want to do that, you can do it like this:
framework: messenger: failure_transport: new_transport transports: new_transport: 'facile-it-mongodb://default'
If you configure this transport multiple times, remember to use the queue_name and/or the collection_name options (see below) to differentiate the messages.
Full configuration reference
This transport, like other default ones, has a number of options available, which can be passed as a query string in the DSN, or as an array below, like in the following example (all values are the provided defaults):
framework: messenger: transports: new_transport: dsn: 'facile-it-mongodb://default' options: collection_name: 'messenger_messages' queue_name: 'default' redeliver_timeout: 3600 document_enhancers: []
The redeliver_timeout option
The redeliver_timeout works in the same way as the DoctrineTransport: when a message is delivered but not acked nor rejected (maybe due to a fatal crash or a network failure), it works as a timeout, and makes the message redeliverable after it expires.
The document_enhancers option
The document_enhancers option is an extension point of this transport; it accepts an array of strings, each of them a fully qualified class name or a service name with the @ prefix.
It allows the end user to add fields to the document that will be persisted for each message. Each enhancer has to implement the Facile\MongoDbMessenger\Extension\DocumentEnhancer interface, which requires the implementation of a enhance(BSONDocument $document, Envelope $envelope): void method. The BSONDocument will be persisted afterwards, and it can be enriched with additional properties, which can be useful for searching and indexing for specific information with i.e. MongoDbTransport::find.
You can take a look at the provided \Facile\MongoDbMessenger\Extension\DocumentEnhancer\LastErrorMessageEnhancer as an example, or use it like this:
framework: messenger: transports: new_transport: dsn: 'facile-it-mongodb://default' options: document_enhancers: - 'Facile\MongoDbMessenger\Extension\DocumentEnhancer\LastErrorMessageEnhancer' # or - '@my_document_enhancer' services: my_document_enhancer: class: App\My\Class # which implements the DocumentEnhancer interface arguments: - '...'
facile-it/mongodb-messenger-transport 适用场景与选型建议
facile-it/mongodb-messenger-transport 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 80.46k 次下载、GitHub Stars 达 6, 最近一次更新时间为 2020 年 05 月 25 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「database」 「symfony」 「mongodb」 「transport」 「Messenger」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 facile-it/mongodb-messenger-transport 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 facile-it/mongodb-messenger-transport 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 facile-it/mongodb-messenger-transport 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Dibi is Database Abstraction Library for PHP
Generates Symfony2 documents, forms and CRUD
Store your language lines in the database, yaml or other sources
The bundle for easy using json-rpc api on your project
A package for automatically encrypting and decrypting Eloquent attributes in Laravel 5.5+, based on configuration settings.
A PSR-7 compatible library for making CRUD API endpoints
统计信息
- 总下载量: 80.46k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 6
- 点击次数: 18
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-05-25