- Execute a task synchronously and asynchronously
- Execute a big job (many tasks) synchronously and asynchronously
- Persist tasks through a storage backend, so they are not lost on restarts or failures
Setup
Require the modules package and enable DTCE in your application:PHP extension prerequisites
swooleextension is required.redisextension is needed if Redis is used as a backend store.rdkafkaextension is needed if Kafka is used as a queue.
Architecture
There are three main components.1. Task Queue
Any executable task is placed in the queue, then processed by a worker. Any queue implementation must implementTaskQueueHandler. This module provides four implementations out of the box.
2. Task Store
Input data to a worker and output data from a worker are stored in the Task Store. Any store implementation must implementTaskIOStorageHandler. This module provides four implementations out of the box.
3. Task Worker
This is the actual implementation of your work. A task worker must implementTaskWorker.
Example worker and execution
The followingWordCounter worker counts the number of words in a string:
TaskExecutionServiceFactory:
DTCE configuration (dtce-config.yml)
A minimaldtce-config.yml assigns a queue handler, a storage handler, and a worker class to a named task: