g4 / messenger
RMQ messenger
Installs: 11 507
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 7
Forks: 2
Open Issues: 0
Requires
- ext-json: *
- ext-pdo: *
- ext-redis: *
- php-amqplib/php-amqplib: >=2.6.1
Requires (Dev)
- g4/code-coverage: 1.*
- phpunit/phpunit: 5.*
- squizlabs/php_codesniffer: 3.*
This package is auto-updated.
Last update: 2024-10-29 06:00:10 UTC
README
messenger library
Install
Via Composer
composer require g4/messenger
To create rbmq messages table run:
php vendor/bin/messenger-create-table --dbname your_db_name --dbport your_db_port --username your_db_username --password your_db_password --host your_db_host
Usage
<?php // create \PDO object with your db params $pdo = new \PDO('mysql:dbname=db;host=127.0.0.1:3306', 'root', '1234'); // publish singe message to RabbitMq with your RabbitMq params (new \G4\Messenger\RabbitMQ\RabbitMq( 'your_exchange', 'your_binding', $pdo ))->sendMessage(['foo' => 'baz']); // publish bulk messages to RabbitMq with your RabbitMq params (new \G4\Messenger\RabbitMQ\RabbitMq( 'your_exchange', 'your_binding', $pdo ))->sendMessageBulk( [ ['foo1' => 'baz1'], ['foo2' => 'baz2'], ['foo3' => 'baz3'], ] ); // create your AMQP connection based on your params $connection = new PhpAmqpLib\Connection\AMQPStreamConnection( 'localhost', '5672', 'guest', 'guest' ); // restore your undelivered message from db and put them back to RBMQ (new \G4\Messenger\Messenger\Messenger( $pdo, $connection ))->restoreMessages(); ?>
Development
Install dependencies
$ make install
Run tests
$ make unit-tests