recommerce / queue-manager
Installs: 20 579
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 11
Forks: 1
Open Issues: 0
Requires
- aws/aws-sdk-php: ^3.0
- zendframework/zend-eventmanager: ^3.1.0
- zendframework/zend-log: ^2.5
- zendframework/zend-servicemanager: ^3.0
Requires (Dev)
- behat/behat: ^3.0
- codeclimate/php-test-reporter: dev-master
- humbug/humbug: ~1.0@dev
- pdepend/pdepend: ^2.0
- phing/phing: ^2.10
- phpmd/phpmd: ^2.2
- phpunit/phpunit: 4.8.28
- sebastian/phpcpd: ^2.0
- squizlabs/php_codesniffer: ^2.3
This package is not auto-updated.
Last update: 2023-03-17 08:30:03 UTC
README
Recommerce queue-manager
This library provides an interface and some implementation to handle queue system.
Current implementations are :
- AWS SQS : Amazon SQS service (using AWS SDK library).
Installation with composer
composer require recommerce/queue-manager:^0.0 composer update
Queue manager events
QueueManager uses zend framework events.
Queue reader events
- QueueReader::NEXT_MESSAGE_START ;
- QueueReader::NEXT_MESSAGE_END ;
- QueueReader::BEFORE_RECEIVE_MESSAGE ;
- QueueReader::AFTER_RECEIVE_MESSAGE ;
- QueueReader::DELETE_CURRENT_MESSAGE.
Usage examples
Queue reader usage
Amazon Web Services
use Zend\ServiceManager\Config; use Zend\ServiceManager\ServiceManager; $config = require 'config/services.config.php'; $config['queue_client'] = [ // For valid value, see adapters in config/services.config.php 'adapter' => 'sqs-client' // Params for constructor // see aws sdk documentation : http://docs.aws.amazon.com/aws-sdk-php/v3/api/class-Aws.Sqs.SqsClient.html 'url' => '<YOUR_SQS_QUEUE_URL>', 'params' => [ 'profile' => 'default', 'region' => 'eu-west-1', 'version' => 'latest', 'key' => '<YOUR_SQS_KEY>', 'secret' => '<YOUR_SQS_SECRET>' ], 'options' => [] ]; try { $serviceManager = new ServiceManager(new Config($config['service_manager'])); $serviceManager->setService('Config', $config); $queueManager = $serviceManager->get('recommerce.queue-manager.queue-reader'); } catch (\Exception $e) { // Problem in queue reader creation } while ($message = $queueManager->getNextMessage()) { // Do some stuff // ... $queueManager->deleteCurrentMessage(); }
Logger (stubs)
use Zend\ServiceManager\Config; use Zend\ServiceManager\ServiceManager; $config = require 'config/services.config.php'; $config['queue_client'] = [ 'adapter' => 'logger-client', 'file_path' => '/tmp/recommerce-queue-manager-logger-client.log' ]; try { $serviceManager = new ServiceManager(new Config($config['service_manager'])); $serviceManager->setService('Config', $config); $queueManager = $serviceManager->get('recommerce.queue-manager.queue-reader'); } catch (\Exception $e) { // Problem in queue reader creation } while ($message = $queueManager->getNextMessage()) { // Do some stuff // ... $queueManager->deleteCurrentMessage(); }