Download the PHP package berlioz/queue-manager without Composer
On this page you can find all versions of the php package berlioz/queue-manager. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download berlioz/queue-manager
More information about berlioz/queue-manager
Files in berlioz/queue-manager
Package queue-manager
Short Description Queue manager
License MIT
Homepage https://getberlioz.com
Informations about the package queue-manager
Berlioz Queue Manager
Berlioz Queue Manager is responsible for processing jobs from a queue using a job handler. It supports advanced features like memory and time limits, signal handling, and customizable worker options.
For more information, and use of Berlioz Framework, go to website and online documentation : https://getberlioz.com
Installation
Composer
You can install Berlioz Queue Manager with Composer, it's the recommended installation.
Dependencies
- PHP ^8.2
- Packages:
- berlioz/helpers
- psr/clock
- psr/container
- psr/log
- psr/event-dispatcher
Usage
Jobs
JobDescriptorInterface
- Definition: Represents jobs that are ready to be pushed into a queue.
- Example: Defining the structure and payload of a task before queueing it.
- Note: A generic
JobDescriptor
class is available for creating new messages quickly. However, you can extend or override this class to provide additional control, such as custom payload validation or specific job behaviors.
JobInterface
- Definition: Manages jobs that have been consumed from a queue.
- Example: Handling retries, deleting jobs after processing, or releasing jobs back into the queue.
JobForQueue
- Definition: Ensures specific jobs are routed to designated queues.
- Example: Assigning priority tasks to a high-priority queue.
Jobs handlers
The JobHandlerManager
is a central component for managing multiple job handlers in the Berlioz Queue Manager. It implements the JobHandlerInterface
and acts as a dispatcher, delegating job processing to the appropriate handler based on the job's name.
The JobHandlerInterface
defines the contract for handling jobs in the Berlioz Queue Manager. Implementing this interface allows you to define how specific jobs should be processed.
Below is an example implementation of a JobHandlerInterface
for consuming and processing a job named "foo"
:
Worker
The Worker
class is the main part of the Berlioz Queue Manager and is responsible for processing jobs from a queue
using a job handler.
Queues
DbQueue
The DbQueue
is a durable implementation of a queue that uses a database to store jobs persistently. This ensures that jobs remain available even in the event of application or server restarts. By leveraging a database, the DbQueue
provides reliability and durability, making it suitable for production environments where job data must not be lost.
Key Characteristics:
- Durable Storage: Jobs are stored in a relational or NoSQL database, ensuring persistence and fault tolerance.
- Transactional Guarantees: Can leverage database transactions to ensure that job insertion, processing, and deletion are atomic operations.
- Scalability: With proper indexing and optimization, the
DbQueue
can handle large volumes of jobs efficiently. - Use Cases:
- Applications that require guaranteed delivery and processing of jobs.
- Scenarios where jobs must survive server or application crashes.
- Environments where job metadata (e.g., retries, priorities) must be tracked over time.
While DbQueue
offers durability and reliability, its performance may be impacted by database latency compared to in-memory queues. It is best suited for scenarios where persistence and fault tolerance are prioritized over low-latency operations.
Example of schema for MySQL:
If you want to keep the jobs treated:
Memory queue
The MemoryQueue
is a lightweight, ephemeral implementation of a queue that stores jobs in memory for the duration of the script's execution. This queue is particularly useful for testing, development, or scenarios where persistent storage is not required. Since the jobs are stored in memory, they are lost when the script ends, making it unsuitable for production environments where job persistence is critical.
Key Characteristics:
- Ephemeral Nature: Jobs exist only during the script's runtime.
- Fast and Lightweight: No external dependencies or storage overhead.
- Use Cases:
- Unit testing or local development.
- Short-lived tasks that do not require durability.
- Simulating job execution flows without external systems.
The MemoryQueue
provides all the standard operations of a queue, such as pushing jobs, consuming jobs, and checking the size of the queue, while maintaining a simple in-memory data structure to manage these operations. However, since it lacks durability, it should be used with caution and only in scenarios where the transient nature of the data is acceptable.
AwsSqsQueue
The AwsSqsQueue
is an implementation of a queue that integrates with Amazon Simple Queue Service (SQS), a fully managed message queuing service provided by AWS. This queue leverages the scalability, durability, and distributed nature of SQS to handle job storage and delivery in a reliable and fault-tolerant manner.
Key Characteristics:
- Fully Managed: Offloads the operational complexity of managing infrastructure, scaling, and maintenance.
- Highly Durable: Messages are redundantly stored across multiple data centers, ensuring data durability and availability.
- Scalable: Capable of handling an unlimited number of messages and automatically scaling to meet demand.
- Low Overhead: Removes the need for a dedicated queue server or database.
- Use Cases:
- Distributed systems requiring reliable asynchronous communication.
- Scenarios with high message throughput or unpredictable traffic spikes.
- Cloud-native applications leveraging other AWS services like Lambda or EC2.
With features like visibility timeouts, message delays, and dead-letter queues, AwsSqsQueue
provides robust mechanisms for handling complex workflows and ensuring job delivery. However, since it is a cloud-based service, its performance depends on network latency and AWS's regional availability.
All versions of queue-manager with dependencies
berlioz/helpers Version ^1.0
psr/clock Version ^1.0
psr/container Version ^1.0 || ^2.0
psr/log Version ^1.0 || ^2.0 || ^3.0