PHP code example of corley / queue-rabbitmq

1. Go to this page and download the library: Download corley/queue-rabbitmq library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

corley / queue-rabbitmq example snippets


use Corley\Queue\RabbitMQ\RabbitMQ;

$amqp = new AMQPStreamConnection('localhost', 5672, 'username', 'password');
$adapter = new RabbitMQ($amqp);

$adapter = new RabbitMQ($amqp, [
    "exchange" => "my_exchange", // send to an exchange
    "receive_timeout" => 20, // exit after 20 seconds
]);

use Corley\Queue\Queue;

$queue = new Queue("my_queue", $adapter);
$queue->send(json_encode(["test" => "ok"]));

list($receipt, $message) = $queue->receive();
$message = json_decode($message, true);

$queue->delete($receipt);
sh
composer