lamoda/tactician-queue

此包已被弃用,不再维护。未建议替代包。

为 Tactician 提供发布命令到 lamoda/queue 库的中间件

1.1.0 2020-02-05 16:30 UTC

This package is auto-updated.

Last update: 2023-06-05 23:07:33 UTC


README

Build Status Scrutinizer Code Quality Code Coverage Build Status

该库提供了中间件,允许您以异步或延迟的方式通过 Tactician 执行命令。

安装

Composer

composer require lamoda/tactician-queue

配置

在使用之前,请查阅 lamoda/queue-bundle 的文档。

该包提供了用于 Tactician 集成的特殊中间件。此中间件增加了对异步命令执行、带有调度的事件的支撑。

要启用此功能,请执行以下操作:

  1. 添加额外配置
    lamoda_tactician_queue:
        tactician_id: tactician.commandbus # Command bus service id
    
  2. 添加至少一种策略,该策略将命令转换为工作项
    services:
        # ...
        several_domain_commands_strategy:
            class: Lamoda\TacticianQueue\Middleware\QueueProducerStrategy\CommandsListToCommandJobStrategy
            arguments:
                - async_command_queue
                - async_command_exchange
                - [ My\AsyncCommandInterface, My\SecondCommand ]
                - 15 # optional delay
            tags:
                - { name: tactician_queue.job_producing_strategy }
  3. 将队列中间件添加到 Tactician 中间件列表中
    tactician:
        commandbus:
            default:
                middleware:
                    - tactician.middleware.locking
                    - lamoda_tactician_queue.middleware # Here it is
                    - tactician.middleware.command_handler
  4. 现在每次您调用
    <?php
    $commandBus->handle(new My\SecondCommand());
    此命令将被发布到队列中。