crysalead / queue
Simple queue consumer framework that supports message dispatching.
Installs: 6 090
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 4
Forks: 0
Open Issues: 0
Requires
- php: >=7.0
- ext-json: *
Requires (Dev)
- aws/aws-sdk-php: ~3.0
- google/cloud-pubsub: ^1.29
- kahlan/kahlan: ~5.0
- microsoft/azure-storage-queue: ^1.3
- pda/pheanstalk: ~4.0
- predis/predis: ~1.0
Suggests
- aws/aws-sdk-php: To add support for AWS Simple Queue Service (SQS).
- google/cloud-pubsub: To add support for Google Cloud Pubsub.
- iron-io/iron_mq: To add support for IronMQ Queue.
- microsoft/azure-storage-queue: To add support for Microsoft Azure Storage Queue.
- pda/pheanstalk: To add support for Beanstalkd queue.
- predis/predis: To add support for Redis based queue and pub/sub functionality.
This package is auto-updated.
Last update: 2024-11-17 23:49:11 UTC
README
Install
composer require crysalead/queue
Basic usage
Create Queue instance
$broker = new Lead\Queue\Adapter\Sqs( "https://queue.url", new SqsClient([ 'version' => 'latest', 'region' => '<region>', 'credentials' => [ 'key'=> '<key>', 'secret'=>'<secretKey>' ] ]) );
Listen on queue
Listening is a blocking call and runs in an infinite loop (up to default 20s polling timout). Your callback will be triggered when a new Message has arrived.
$broker->listen(function($job) { if (!$job) { return; } /** * * Process the job... * */ // Delete the job from Queue. $job->delete(); });
Shutting down the Queue
You may shutdown the queue by using the shutdown()
method.
The Queue instance will respond to PCNTL signals in a safe manner that will not interrupt in the middle of Message processing. You can install signal handlers in your code to cleanly and safely shutdown the service.
pcntl_signal( SIGINT, function() use ($broker) { $broker->shutdown(); } );
Acknowledgements
- Syndicate (this repo is a simple fork of his brillant work).