thomasvargiu / zf-messenger
此包已被弃用,不再维护。作者建议使用 thomasvargiu/laminas-messenger 包。
用于在 ZF2 和 expressive 应用程序中使用 Symfony Messenger 的 ZF 工厂
0.2.0
2019-11-28 16:45 UTC
Requires
- php: ^7.1
- psr/container: ^1.0
- symfony/event-dispatcher: ^4.3 || ^5.0
- symfony/messenger: ^4.4 || ^5.0
- zendframework/zend-servicemanager: ^3.0
Requires (Dev)
- doctrine/dbal: ^2.7
- doctrine/orm: ^2.4
- facile-it/facile-coding-standard: ^0.3.1
- friendsofphp/php-cs-fixer: ^2.16
- phpstan/phpstan: ^0.11.19
- phpunit/phpunit: ^7.5 || ^8.4
- psr/cache: ^1.0
- psr/log: ^1.1
- vimeo/psalm: ^3.6
- zendframework/zend-config-aggregator: ^1.1
Suggests
- doctrine/dbal: To use doctrine transport
- doctrine/orm: To use doctrine ORM middlewares
- psr/cache-implementation: To use stop workers command
Conflicts
This package is auto-updated.
Last update: 2020-01-21 16:47:10 UTC
README
归档项目
此项目已被弃用。您应使用 thomasvargiu/laminas-messenger
。
用于在 ZF2 和 expressive 应用程序中使用 Symfony Messenger 的 ZF 工厂
使用方法
您需要将控制台命令添加到您的应用程序中。以下命令服务已经为您配置:
Symfony\Component\Messenger\Command\ConsumeMessagesCommand
Symfony\Component\Messenger\Command\SetupTransportsCommand
Symfony\Component\Messenger\Command\FailedMessagesRemoveCommand
Symfony\Component\Messenger\Command\FailedMessagesRetryCommand
Symfony\Component\Messenger\Command\FailedMessagesShowCommand
Symfony\Component\Messenger\Command\StopWorkersCommand
(见下文说明)
要使用 Symfony\Component\Messenger\Command\StopWorkersCommand
命令,您应设置一个 CacheItemPoolInterface
实现(见下文)。
已为您配置了默认的消息总线,服务名称为: messenger.bus.default
。您可以通过阅读 Symfony 文档 了解如何使用它。
配置
以下是一个配置示例
use TMV\Messenger\Factory; use Symfony\Component\Messenger; return [ 'dependencies' => [ 'factories' => [ 'messenger.bus.foo' => [Factory\MessageBusFactory::class, 'messenger.bus.foo'], // the name must be the same as the bus configuration key 'messenger.transport.async' => [Factory\Transport\TransportFactory::class, 'messenger.transport.async'], // the name must be the same as the transport configuration key ], ], 'messenger' => [ 'failure_transport' => null, // your failure transport service name (optional) 'logger' => null, // your custom logger service name (optional) 'default_serializer' => SFMessenger\Transport\Serialization\PhpSerializer::class, // default messenger serializer, it should be a service name 'cache_pool_for_restart_signal' => null, // CacheItemPoolInterface service name implementation if you want to use stop workers command 'transport_factories' => [ // here you can add your custom transport factories services ], 'buses' => [ 'messenger.bus.foo' => [ // bus service name, it should be registered as a service with the same name 'default_middleware' => true, // if you want to include default middleware (default: true) 'middleware' => [ // your custom middleware service names My\FooMiddleware::class, ], 'allow_no_handler' => false, // allow no handlers (default: false) 'handlers' => [ // your handlers My\FooMessageType::class => [ My\FooMessageHandler::class, ], ], 'routes' => [ My\FooMessageType::class => ['messenger.transport.async'], // route message types to this transport ], ], ], 'transports' => [ 'messenger.transport.async' => [ 'dsn' => 'amqp://guest:guest@rabbitmq:5672', 'serializer' => Messenger\Transport\Serialization\PhpSerializer::class, // custom serializer service 'options' => [ 'exchange' => [ 'name' => 'messenger_events', ], 'queues' => [ 'messenger_events' => [], ], ], 'retry_strategy' => [ 'max_retries' => 3, 'delay' => 1000, 'multiplier' => 2, 'max_delay' => 0, ], ], ], ], ];