Skip to main content
Version: 4.0

Architecture

architecture.png

The Batch Messenger Bundle is designed around a queue system, specifically tailored for managing sequential, resource-intensive tasks. This system leverages the Symfony Messenger Component for efficient task processing.

Task Structure

Task

A Task is an aggregate of multiple Task Items, designed to be processed collectively by a Task Processor. To enhance efficiency, Tasks are batch-processed (e.g., 10 Task Items at a time). This batching approach is particularly beneficial for resource-heavy operations.

Task Item

Each Task Item represents an individual unit within a Task, processed by a Task Item Processor. These items carry the actual data to be processed and can vary in nature, encompassing jobs like locking mechanisms, adding files to a zip, or making API calls. After processing, Task Items are marked as completed, and the system proceeds to the next Task.

Middleware

Middleware acts as a pre-and post-processor for both Tasks and Task Items. It can be utilized for various preparatory and cleanup activities, such as transferring files between remote and local locations.

You can create a new Middleware by implementing the CoreShop\Bundle\BatchMessengerBundle\Middleware\MiddlewareInterface and register it with the coreshop_batch_messenger.middleware tag.

You can see a good Example of that with the ZipMiddleware. It creates a temp Zip File before the Task is processed and deletes it afterward.

Task Processor

The Task Processor is responsible for the actual execution of Tasks. It processes the data contained within Task Items, executing the core PHP code required for each task.

For further insights into Custom Task Item Processors and Task Item Data, refer to this article.