Bridge with ``symfony/messenger`` ============================================================ Refer to the `official documentation `__ on Symfony's website. | This bridge provides a way launch job using message bus. | Along with ways to interact with messenger inside jobs. Launch Job through Messenger dispatcher ------------------------------------------------------------ The `DispatchMessageJobLauncher `__ execute jobs via a symfony command message dispatch. A `LaunchJobMessage `__ message will be dispatched and handled by the `LaunchJobMessageHandler `__ will be called with that message after being routed. How to configure an async transport for the launcher? ------------------------------------------------------------ You first need to configure an async transport, like explained `in Symfony’s doc `__. Then you will have to route the message to this async transport you created, like explained `in Symfony’s doc `__. You will end with something like: .. code-block:: yaml # config/packages/messenger.yaml framework: messenger: transports: async: "%env(MESSENGER_TRANSPORT_DSN)%" routing: 'Yokai\Batch\Bridge\Symfony\Messenger\LaunchJobMessage': async .. seealso:: | :doc:`What is a job launcher? ` | :doc:`Getting started with Symfony Framework ` | :doc:`Bridge with Symfony Framework ` How to configure different transport for your jobs? ------------------------------------------------------------ On some projects, you will end with different messenger transports, and will not want to run all jobs on the same transport. | Because we are using the same message class for all jobs, there is no way to configure this in Symfony. | Instead, you will have to configure a job name to transport routing, in our side of the configuration. | It is very likely to the messenger routing configuration, but you will use the job name instead of the message class. .. code-block:: yaml # config/packages/yokai_batch.yaml yokai_batch: launchers: messenger: routing: export_job_name: async_with_low_priority import_job_name: async_with_high_priority .. seealso:: | :doc:`What is a job launcher? ` | :doc:`Getting started with Symfony Framework ` Dispatch item with messenger writer ------------------------------------------------------------ | This item writer will dispatches each item through Symfony's messenger bus. | Items must be objects that messenger can handle. .. literalinclude:: symfony-messenger/dispatch-each-item-as-message-writer.php :language: php .. seealso:: | :doc:`What is an item writer? `